Containers, VMs and the Docker architecture
Docker made containers practical: package an application with its runtime and dependencies into an image, and run it the same way on a laptop, a CI agent, or an EKS node. Most DevOps engineers use it every day; senior interviews go underneath the commands — how images and layers are stored, what a container actually is to the kernel, how BuildKit caching works, how networking is wired with veth pairs and iptables, and how to build images that are small, reproducible and secure enough for a regulated production environment.
What a container really is
A container is an ordinary Linux process started with:
- Namespaces — its own view of PIDs (it sees itself as PID 1), network interfaces and ports, mounts, hostname, IPC and (optionally) user IDs.
- cgroups — limits and accounting for CPU, memory, block I/O and number of PIDs.
- A root filesystem assembled from image layers.
- Security restrictions: dropped Linux capabilities, a seccomp profile that blocks dangerous syscalls, and AppArmor/SELinux confinement.
Run docker run -d nginx, then ps aux | grep nginx on the host — you'll see the nginx processes. There's no hidden VM on Linux.
Containers vs virtual machines
| Containers | Virtual machines | |
|---|---|---|
| Isolation boundary | Shared host kernel; namespaces + cgroups | Hypervisor; each VM runs its own kernel |
| Start time | Milliseconds to seconds | Tens of seconds to minutes |
| Size | MBs (app + libraries) | GBs (full OS) |
| Density | Hundreds per host | Tens per host |
| Security | Weaker boundary; a kernel exploit can escape | Stronger boundary |
| OS flexibility | Must match host kernel type (Linux containers need a Linux kernel) | Any OS |
They're complementary: on AWS your containers run inside EC2 VMs. Firecracker micro-VMs (used by Fargate and Lambda) combine VM-level isolation with near-container start times. On macOS and Windows, Docker Desktop runs a small Linux VM, which is why bind mounts are slower there.
The engine stack
- docker CLI — just a client.
- dockerd — the Docker daemon: images, builds (BuildKit), networks, volumes, the API.
- containerd — the container runtime daemon (a CNCF graduated project): pulls images, manages snapshots and container lifecycles.
- containerd-shim — one per container; keeps it running if containerd restarts and holds its stdio.
- runc — the low-level OCI runtime that actually creates namespaces and cgroups, then execs your process, and exits.
Anyone with access to /var/run/docker.sock controls dockerd — which runs as root — so mounting the socket into a container (a common CI shortcut) hands that container root on the host.
OCI standards and Kubernetes
The Open Container Initiative defines:
- the image spec (manifest, config, layers),
- the runtime spec (how runc-like runtimes start a container),
- the distribution spec (registry API).
That's why an image built by Docker runs unchanged on containerd, CRI-O or Podman. Kubernetes removed dockershim in v1.24 — kubelet talks to containerd directly via the CRI. Your Docker-built images still run fine on EKS; you just can't use docker commands on the node (use crictl instead).