Docker is very famous for both software development and deployment; it is used everywhere. The idea is to use the same environment on each machine in the whole cycle of software development and deployment. Previously, it was already possible to simulate the production environment with virtual machines (VMs). So what is this concept of VMs and how is Docker different from VMs?
Problem of Programming and Deploying on Different Machines
Programming happens on the developer’s local machine. Usually, this machine has a different setup from the machines of other developers and the servers where the programme should be deployed on. These environments behave differently and code which worked on one machine might not work on another machine. Therefore, the idea is to create the same environment on all the machines involved.
Concept of Virtual Machines
The idea of VMs is to simulate a complete computer. Working on a VM is like working on another computer. Additionally, you could run multiple VMs on one computer. Each VM of the developers should be set up like the servers used in production. Then, problems that arise because of varying development environments and the differences between development and production environments will not occur anymore.
The repository used for development also includes a Provisioning File describing how the environment should be set up (which software should be installed). This file is used to set up the VM of each developer and the remote servers where the software should be deployed on. The code is still shared via a VCS (e.g. Git) and, finally, deployed on the servers.
Concept of Docker
Docker has a different idea. When installing Docker, the Docker Daemon is installed automatically. The Docker Daemon does not serves as a virtual machine but it controls the containers. It should run when using docker. In this case, the previously mentioned Provisioning File is called Dockerfile. Its content describes how to build an image with the Project Code. The image serves as a blueprint for containers which could run on any machine with Docker. This image could be published in a registry (e.g. Docker Hub). Then, an image could be pulled from the registry and run on any machine. For collaboration between different developers, the code is still shred via a VCS (e.g. Git).
Comparison Between Docker and VM Systems
The main difference between Docker (in general, container system) and VM systems is that Docker creates containers running on the machine; the binaries use the same kernel like the OS. Whereas VM systems create complete new machines with an own OS on the host system. This results in a redundancy of operating systems and, therefore, in a waste of resources.
The diagram shows only one application running in each VM but several applications could be run in a VM.
However, the encapsulation of VMs is stricter and results in a higher security. Thus, putting together the two technologies would minimise the disadvantages of each technology while combining their advantages.
In this example, several VMs are run on the Host OS. Each VM could run multiple Docker Containers. Though, a VM does not have to run any Docker container; it could also be used without any container technology.
Even though Docker is very famous and nearly omnipresent, there are many alternative container systems and also systems used for the management of images and containers created with Docker.