A Container Shares the Host Kernel, a Virtual Machine Runs Its Own
A container packages an application with its dependencies so it runs the same everywhere, but it is not a small virtual machine. It's an ordinary Linux process isolated by kernel features and sharing the host's kernel. That's why containers start in milliseconds and stay light, and also why their isolation is weaker than a VM's.
How the Isolation Works
| Kernel feature | Isolates |
|---|---|
| Namespaces | what the process sees: its own process tree, network interfaces, mount points, hostname, users |
| cgroups | what it may use: CPU, memory, I/O limits |
| Layered filesystem (OverlayFS) | the image's read-only layers plus a thin writable layer per container |
The image carries the application, libraries and a userland (a Debian or Alpine base), never a kernel.
Containers and VMs Compared
| Container | Virtual machine | |
|---|---|---|
| Kernel | the host's, shared | its own, on a hypervisor |
| Startup | milliseconds | seconds to minutes |
| Size | megabytes | gigabytes |
| Isolation boundary | the kernel: one kernel bug can affect every container | the hypervisor: much smaller attack surface |
| Runs another OS | no: Linux containers need a Linux kernel (Docker Desktop runs a hidden VM on macOS and Windows) | yes |
References
- Docker and Container Security MOC - hub for container notes.
- Non-Root Container Filesystem Ownership and Persistent Media Volumes - running as a non-root user in practice.
- Docker documentation: What is a container? - containers vs VMs.
- Linux man-pages: namespaces(7) - the namespace types.
Review cards
Flashcard What do namespaces control for a container process?
What it can see: its own process tree, network interfaces, mount points, hostname and users. Limits on what it may use (CPU, memory, I/O) come from cgroups.
Flashcard Why does a container start in milliseconds when a VM takes seconds or minutes?
A container is an ordinary process on the host's already running kernel; a VM must boot its own kernel and operating system on a hypervisor.