Docker container vs VM: what is shared and what is copied

By Christophe Paka · Facts checked on 7 November 2026

You read that a container is "like a lightweight VM." Then you read that it is not. Both sound sure of themselves, and you still cannot say which is right.

Here is the short answer to Docker container vs VM. A virtual machine copies a whole operating system for every app. A container copies only the app and its files, and borrows the kernel of the machine it runs on. The figure below draws both stacks side by side, so you can see exactly what is repeated and what is shared.

Two stacks. Left, virtual machines: three apps, each with its own guest operating system and kernel, on a hypervisor on hardware. Right, containers: three apps with libraries as processes on one shared host kernel on hardware.
Figure 2.1: One kernel, many walls. A VM copies a whole operating system; a container copies only the app and its files.
Use this diagram on your site

Free to share in your blog post, docs, course or slides, as long as the credit link stays. Paste the code below where the figure should go.

How to read this figure

  1. Start at the hardware. Both stacks stand on the dark bar at the bottom: the physical computer. In both worlds the hardware is shared. That is the only thing the two sides have in common.

  2. Read the VM stack upward. On the left, a hypervisor sits on the hardware. It is the software that splits one computer into several virtual ones. Each VM holds a guest OS with its own kernel, drivers and system programs, then the app's libraries, then the app.

  3. Spot the repeats. The orange boxes say an entire operating system per VM, duplicated again, and again. That repeated block is the price of a VM. Each one boots like a computer, and the wall between VMs is simulated hardware.

  4. Read the container stack upward. On the right, a blue bar sits on the hardware: the host OS, one shared kernel. The container runtime, Docker Engine, asks that kernel to isolate each process. On top, each container holds only an app and its libraries.

  5. Notice what is missing. There is no guest OS and no second kernel. Each container is a process. It starts like a program opening, not like a computer booting. The isolation boundary is the shared kernel itself.

  6. Read the two captions. At the bottom of the left stack: shared is the hardware only, duplicated is an entire OS. On the right: shared is hardware plus kernel, duplicated is app and libraries only.

Key takeaways

  • Think of a container as one process with walls around it, never as a small virtual machine.
  • Remember that every container on a machine shares that machine's one kernel, while each VM brings its own.
  • Use a stronger box than a container for code you do not trust, because one kernel bug reaches every container.

Worked example: the houses and flats picture

Turn the two stacks into buildings. It is a picture, so it has an edge, and the last step shows where it breaks.

  1. A VM is a separate house. It has its own foundation, pipes and boiler. That foundation is its own kernel.
  2. A container is a flat in one building. It has its own front door and address, which is what a process may see. It also has its own meter, which is what it may use.
  3. All the flats stand on one foundation and share one set of pipes. That foundation is the shared kernel.
  4. Where the picture breaks: a crack in a shared foundation reaches every flat at once. That crack is a kernel bug or a bug in the runtime. A row of houses would not share it.

Result: Containers are lighter because they share. VMs have the stronger wall because they do not. Cloud providers run containers inside VMs to get both.

Questions readers ask

Is a Docker container a small virtual machine?

No. Docker's own docs call a container "an isolated process with all of the files it needs to run." A VM is a whole simulated computer with its own operating system. A container has no second kernel and no guest OS, so it is a walled off process, not a small computer.

Why can containers share one kernel?

Two Linux features build the walls. Namespaces decide what a process can see, and cgroups decide how much it may use. The next figure opens a container up and shows both.

If containers need a Linux kernel, how does Docker run on a Mac or Windows PC?

Docker Desktop runs a small hidden Linux virtual machine, and your containers live inside it. A Mac or Windows machine has no Linux kernel of its own, so it borrows one from that VM.

Which wall is stronger, a VM or a container?

The VM wall. An escape from a VM must also break the hypervisor. A container wall is made of kernel features, which makes it lighter but weaker. The two are not rivals: cloud providers run containers inside VMs.

Sources: What is a container? (Docker docs); The Magic Behind the Scenes of Docker Desktop (Docker blog); Containers vs VMs (Red Hat).

This figure is from Docker Made Crystal Clear, chapter 2.

The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.

Get the book

All diagrams