What is Docker? Why is it necessary ?Explained in simple terms.

Swarali Tannu
4 min readMay 27, 2021

We will understand what is docker?

How it works and why it is better than virtual machines?

Earlier there existed some common problems in the software industry before the arrival of of docker .When a developer used to develop an application it work fine in his own environment but when the same application reached production it won’t work properly. This problem occurred due to the difference in the computing environment of Dev and product.

Another problem was with the implementation of microservices. In case you don’t know what micro services are ,generally large applications are broken down into small services called microservices. They can also be seen as small processes which communicate with each other over a network to fulfill one particular goal. For example an online shopping service can be broken down into smaller services like account service product catalogue cart server and order server. Microservices architecture is popular because it offers some advantages such as some application become easier to maintain when they are broken down into smaller services . Whenever required modifications can be brought in a single service without wearing much about the dependencies of other services . Another benefit is that when one service goes down then it does not have a huge impact on the whole application. So before docker microservices were deployed using virtualization. Multiple virtual machines where installed on a single host machine individual virtual machines used to run individual microservices. The disadvantage of this approach was that it used to cause the wastage of resource as the microservices running in this virtual machines were not using the full potential of the memory, processing power ,disc space, etc. of the virtual machines. When there are hundreds of such microservices running, the wastage becomes huge. So how docker solves the problem ? The implementation of docker is a little different from virtualization. In the case of docker a Linux or Unix based virtual machine is installed on the host machine. On top of these virtual machines, there are multiple docker containers which are responsible for running each microservice.

The advantage of using containers instead of virtual machine is that, unlike a virtual machine, a docker container does not require you to Pre allocate memory or disk space. The container takes the resources according to the need of the application. So this is how doctor helps us in optimum utilization of resources.

Now let us see how docker solve our first problem of inconsistent environments. Docker container swap a piece of software in a complete file system that contains everything needed to run: code, runtime, system tools, system libraries — anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment. Containers include the application and all its dependencies. Docker containers are not tied to any specific infrastructure: they run on any computer, or on any infrastructure and in any cloud. So this was a brief introduction to docker.

What is Docker & Docker Container ?

What is Docker & why is Docker needed? — Docker is a containerization platform that packages your application and all its dependencies together in the form of a docker container to ensure that your application works seamlessly in any environment.

What is Container ? — Docker Container is a standardized unit which can be created on the fly to deploy a particular application or environment. It could be an Ubuntu container, CentOs container, etc. to full-fill the requirement from an operating system point of view.

So here I have created a Python application For Salary Prediction

>>So, you need to install Docker first on your OS.

After installation, we pull the Docker container image of the OS. Here I’m going to pull Centos image from Docker Hub.

The command to pull is:

>>As I have launched the OS by naming is “st21”,here I start docker with command:

docker start st21

>>Installation of Python on the top of docker container.

>>Then I have created a machine learning model in the container , that I previously created in Jupyter notebook.

>>By using Linear Regression in Python3 I was finally able to predict salary for the given database and I got the expected results.

Thank you for reading!!

--

--