Docker Vs. Virtual Machines: Understanding the Differences

Abdullah Jimoh
3 min readAug 15, 2022

To understand the difference between both terms, we need to know how they both work on an Operating system level (OS) and what an operating system consists of.

Stay with me while we break this down into smaller bits.

Operating System

Operating systems are software that helps in operating both hardware and software of an application and manages all the application programs in a computer.

An OS is inclusive of two layers: OS Kernel and Application.

OS Kernel: is the primary interface between the application and the hardware components of the system.

Application: Applications are user processes that create the user’s space and are controlled by the OS Kernel. OS kernel enables these processes to communicate with each other.

A visual architecture of a computer hardware

Hardware: The hardware is a physical machine that accommodates physical components that require the system to function. These components are memory, Central Processing Unit(CPU), and input/output(I/O) components such as graphics, networking, and storage.

Docker and Virtual Machines

Have you ever heard of the famous saying: “It works on my machine!”. While this is often referred to as a joke, it also illustrates the complexity of deploying software. Docker solves this problem using containers.

Docker is a lightweight virtualization technology tool that makes it easy to develop, build, deploy and manage applications using containers.

A container is a way to package an application with all the necessary dependencies and configurations, and this package is portable and easily shared between a development team or development and operation team. The portability of the container and its addition to being packaged in one isolated environment makes development and deployment more efficient.

What are Virtual Machines?

Virtual machines are software that simulates a whole computer and runs on your physical machine. It provides an isolated environment for running its Operating System and application. They can also be referred to as computer resource that uses software to run programs, build, develop, test, and deploy applications.

The virtual machine runs as a user process on your physical machine similar to other applications.

Types of Virtual Machines

The types of VM are classified into two: System virtual machines and Process virtual machines.

System Virtual Machines: A system virtual machine is an entire operating system that operates on virtual hardware inside the host computer.

Process Virtual Machines: They are application VMs that enables a specific program to run on any OS. The process virtual machine is designed to mask information of the underlying hardware and operating system.

Docker and Virtual Machines are both virtualization tools. The question here is; What part of the OS do they virtualize?

Docker virtualizes the applications layer of the Operating system and some other applications. Docker uses the OS Kernel of the host because it doesn’t have its Kernel.

Virtual machines have the application layer and its Kernel. The VM virtualizes the complete OS which means when you download a VM image on your host, it doesn’t use your host kernel but boots up its OS Kernel.

Comparisons

The following are the differences between Docker and Virtual Machines.

Size: Docker containers are much smaller and take little space compared to virtual machines, and they run as isolated processes versus virtualized hardware. Virtual machines take GBs while containers take up MBs.

Performance: Virtual machines are larger and slower to boot. They simulate a physical machine and are resource intensive because they need to load the entire OS to start. Containers are lightweight architecture and can spawn up quickly in seconds.

OS and Architecture: Docker containers host on a physical server with the host OS. They are suitable to run on multiple applications over one OS Kernel.

Virtual Machines have Guest OS inside each VM and also have host OS. The Guest OS is usually any OS: Linux or Windows, irrespective of the Host OS.

Conclusion

Docker and Virtual machines are virtualization tools built for different use cases. They each have different roles in software engineering and development, and I hope this article will guide your decision on when and how to use these technologies.

--

--

Abdullah Jimoh

Software Engineer | DevOps Engineer | Technical Writer