Virtual Machines Vs Docker Containers –
VMs can be compared with containers on below factors –
- Execution – The VM model blends an application, a full guest OS, and disk emulation. In contrast, the container model uses just the application’s dependencies and runs them directly on a host OS.
- Isolation – Containers do not launch a separate OS for each application, but share the host kernel while maintaining the isolation of resources and processes where required.
- Boot time – The fact that a container does not run its own OS instance reduces dramatically the overhead associated with starting and running instances. Startup time can be drastically reduced to few seconds as compared to VMs which generally takes several minutes to boot up.
- Scalability – The number of containers running on a typical server can reach dozens or even hundreds. The same server, in contrast, might support 10 to 15 VMs.
Below diagram show the differences between VMs and Containers –
Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), can handle more applications and require fewer VMs and Operating systems.
Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers. The hypervisor allows multiple VMs to run on a single machine. Each VM includes a full copy of an operating system, the application, necessary binaries and libraries – taking up tens of GBs. VMs can also be slow to boot.
Please find below video explaining the above concept.