Docker Container Comparison with Virtual Machines.
Docker uses host OS instead of guest os it contains docker engine with the help of this docker engine, Docker containers are formed and these containers have an application running inside them as well the required binaries and libraries are packaged into the same container.
Let us understand why we need Docker?
Most common problems-
The most common problem while developing an application is that the application works on a developer’s machine but not in testing and production environment due to different environments.
Let’s look at the next problem:
Before preceding to next problem lets understand what are microservices?
Suppose we have a very large application that application is split down into small individual services which communicate with each other over the network these services are called as microservices.
Problems in adopting microservices:
you can see multiple virtual machines running on top of host machines each of virtual machine contains dependency of one microservice
Resources, ram, processor and disk space is not fully utilized in this architecture in the example, there are only 5 microservice but what if there are more of them, consider an application containing 50 microservices, in this case, it doesn’t make sense to deploy microservice on Virtual machine.
How docker solve this problem?
There is a host machine and on the top of the host machine there is a virtual machine and on the virtual machine, there are docker containers which contain dependency for one microservice per docker container.
So what’s the difference?
Docker containers are a lightweight alternative of virtual machines i.e in docker container we don’t need to pre-allocate disk space or ram it allocates all the resources depending on the requirement.
For the first problem :
Docker containers can be used throughout the complete SDLC cycle in order to provide consistency in computing so the same environment will be present in dev, test, and prod.
docker in detail:
here developer writes a docker file which contains instructions for application requirements, dependencies.This Dockerfile produces a Docker image and Docker containers are the instance of these images.These images are then uploaded to Docker Hub basically, docker hub is just like GitHub where we can store images and later they can be pulled for the further usage thus giving the same environment for dev, testing, and production.
In the previous example, we saw that the images were stored on docker hub as well the images were huge in size and the testing dev and production team were pulling these images from the hub which require huge bandwidth in order to save that network bandwidth we use the following the workflow.
In the following workflow, Dockerfile is written by the developer and the code is pushed to git repo from git repo CI server like Jenkins pulls the code and build images and these images will be deployed on testing, dev, and production environment this solves the first problem.