Skip to content

Why containers: from bare metal to VMs to containers

Select an icon to see what it is.

Step 6 of 6

What you gain and what you give up

You gain portability, light isolation and fast scaling: many containers fit on one host. You give up some isolation, because all containers share one kernel, which makes a kernel bug more serious than in a VM. Linux containers also need a Linux kernel, which is why Docker Desktop runs a small Linux VM on macOS and Windows.

PrevNext

VM or container?

VM: own kernel, stronger isolation, heavier
container: shared kernel, light and fast, isolation by namespaces and cgroups
they combine: containers often run inside VMs in the cloud

Try it yourself

Check that a container shares the host's kernel and ignores the host's Python. On Docker Desktop, the kernel shown is the one in Docker's Linux VM.

$ uname -r
$ docker run --rm alpine uname -r
$ python3 --version
$ docker run --rm python:3.10-slim python --version
$ docker run --rm python:3.12-slim python --version

Quiz

1. What does a container share with the host that a VM does not?
2. Why does an image fix "it works on my machine"?
3. Why does Docker Desktop run a Linux VM on macOS and Windows?