Docker is becoming more and more popular as a DevOps tool. It has the ability to quickly deploy applications, and is also pretty cool in terms of what you can build with it. But you might be wondering, if it’s so awesome, can we say Docker is a VM? See the answer below.
What is Docker
Docker is an open source technology that enables developers to build applications more efficiently. It was released in 2013. Docker uses containers to package and run the applications. It basically provides a way to build and test applications locally. Then you can deploy these applications to the target environments (usually servers). There are a number of Docker-related technologies like Docker-compose and Docker storage, which are also very interesting in their own right.
How Docker works?
Docker is built on top of containerd, a container runtime. It allows you to build and deploy containers in order to make and manage applications. Applications are typically container images, which are built using a containerizer (such as Docker) and then run with the containerd runtime.
With Docker, you have the ability to create multi-container applications, which are composed of multiple container images. You can use several different container configurations to package and run your application in a container. Each Docker image is built and managed as a layer in a Dockerfile, which contains the instructions to build the Docker image and to run it.
Essentially, what Docker does is wrap an application into a Docker image, so that when you run the container, it will automatically run the application within.
The beauty of Docker is that the code of the application doesn’t change. So it’s the Docker image that changes. You can keep a running container image around so that you can always spin up a new container using the same Docker image, and it runs your same application.
What is a container?
Container is a user-land environment with its own filesystem, dynamic libraries, settings and programs. A container is usually isolated from the host user space and only shares filesystem, network and other resources with the container itself.
Containers provide a way to group software in a way that is very useful in terms of resource management, and this is one of the core strengths of containers. Containers allow you to separate an application into a small environment which you can run as a single process.
For example, you can create a container with server environment. To achieve this, you create a Dockerfile, where you write what you want to have in container. Typically, it is MySQL, web server and other software.
Difference between container and VM
See the image, which explains the difference between concept of virtualization and containerization:
In contrast to virtual machine, Host kernel is shared with Docker container.
The key difference between Docker containers and Virtual Machines is the kernel. Container uses host kernel (the host is machine which runs the container/VM). Virtual machine uses its own virtualized kernel. How is Docker different from VM? Here is a list:
- VM has its own kernel and drivers, while container uses host kernel.
- Containers are more lightweight, while VMs are huge.
- VMs are more isolated.
- Hypervisors: for VM – QEMU (with KVM/Xen), Virtualbox; for containers – Docker.
- Containers are more used for DevOps.
- Virtual machines are enough secure for isolating malware.
- With virtual machine you can emulate hardware.
So, is Docker a VM?
You can think of Docker as virtualization technology, because it virtualizes the environment. However, it is different from Virtual Machines, because containers have no their own kernel. Therefore, full virtualization is impossible with Docker and if you need it – go ahead with VMs. But for regular DevOps tasks it is just fine.