Skip to content

Lesson 3 of 9 · 20m

The OCI Stack: dockerd, containerd, runc, and Friends

Docker isn't one program — it's a stack of standards-conforming components. Knowing which layer does what tells you where to look when things break and what you can swap out.

In 2015 the industry standardised the pieces under the Open Container Initiative, and the modern Docker stack is the result. Three standards matter: the image spec (what a tarball of layers means), the runtime spec (what a running container is), and the distribution spec (how registries speak). Everything you run is composable because of them.

The actual stack when you type docker run

docker CLI
  └─ dockerd          (REST API, auth, networking, orchestration sugar)
       └─ containerd  (image pull/unpack, snapshot management, supervision)
            └─ runc   (writes the OCI config.json, creates namespaces/cgroups, execs init)
                 └─ the kernel

runc is the only part that creates a container, and it's a few thousand lines around the clone/unshare syscalls. Everything above it is convenience. You can watch the layers independently: ps aux | grep containerd on any Docker host shows containerd-shim processes — one per container, so containers survive dockerd restarts. That architecture is why systemctl restart docker (mostly) doesn't kill your workloads.

Why Kubernetes dropped Docker but nothing changed

When Kubernetes removed dockershim in v1.24, operators panicked — and nothing happened, because Kubernetes had only ever needed containerd. Docker the product is a UX layer; the runtime underneath is the same either way. Images built by Docker are OCI images and run identically under containerd, CRI-O, or podman. The corollary: docker commands for debugging (docker exec) don't exist on a containerd-only node — learn crictl and ctr for those environments:

crictl ps                       # like docker ps, CRI-flavored
crictl logs <id>                # reads the kubelet's log files
ctr -n moby images ls           # containerd's own CLI, namespace-aware

Swappable bottoms: not all "containers" share a kernel boundary

The runtime spec has multiple implementations, and the choice is a security posture:

  • runc — the default. Shared kernel, namespace isolation. Fast, thin, and your kernel is the attack surface.
  • gVisor (runsc) — user-space kernel in the sandbox intercepts syscalls. Heavy syscall filtering, some perf cost, much smaller host attack surface. Used for running untrusted customer code (it's what GCP Cloud Run uses).
  • Kata Containers — each container in a lightweight VM. Real kernel isolation, near-container startup times.
docker run --runtime=runsc --rm alpine uname -r   # notice: not your host kernel version

Field notes

  • If a container survives a docker restart but dies during containerd restart, you know which layer owns supervision — plan upgrade order accordingly.
  • docker and podman images are interoperable because of OCI; build with one, run with the other, no conversion.
  • gVisor isn't free — expect 2-10x syscall overhead on IO-heavy workloads. Benchmark before mandating it.
  • The shim-per-container design is why kill -9 on dockerd is survivable but corrupting containerd state is not. Back up nothing, but restart the right thing.

Was this lesson helpful?

Sign in to rate