Virtualization 101 : Docker VS Hypervisor - A brief introduction
In a virtual machine environment the virtualization happens at the hardware level.
The hypervisor virtualizes the resources of the machine it is running on, including storage, network interfaces and memory,...
It then splits these virtualized resources between the different virtual machine which are seen from the outside as separate "real" machines with their own CPU, RAM,....
Hypervisors turn one machine into multiple machines.
Microsoft Hyper-V and VMware ESXI are a couple of bare-metal (Type1) Hypervisor examples.
Type 2 hypervisors, also called hosted hypervisors sit on top of an operating system.
Examples of these hypervisors are Virtual box and VMware workstation.
As opposed to hypervisors that offer hardware virtualization, containers offer operating system level virtualization.
They isolate processes from each other using control groups and namespaces.
Namespaces: each process exists only in one namespace (process id, network, mount (filesystem), user,... ).
Control groups: makes it possible for us to allocate resources like CPU cycles, memory, bandwidth,...
The docker daemon, in a sense plays the role of the hosted hypervisor.
It sits on top of the host OS and manages the interaction between the host OS and the Docker containers and the allocation of the host resources to the different containers,...
The Docker daemon runs the Docker image inside the containers. An image is snapshot (template) of the application and all the libraries it needs to be able to run.
The docker file is a list of instructions on how how to build a docker image.
Images are still templates that could run inside containers which are basically running instances of images
Example of a docker image:
Docker images come in layers. The above docker image have four layers.