Container Internals Deep Dive 04: containerd Internals
Understand containerd architecture: content store, snapshotters, runtime shims, and lifecycle flow.
On this page
Container Internals Deep Dive — this post is part of a series
- Part 1: Container Internals Deep Dive 00
- Part 2: Container Internals Deep Dive 01: Cgroups
- Part 3: Container Internals Deep Dive 02: Namespaces
- Part 4: Container Internals Deep Dive 03: Network Namespaces and CNI
- Part 5: Container Internals Deep Dive 04: containerd Internals
- Part 6: Container Internals Deep Dive 05: OCI Standard
- Part 7: Container Internals Deep Dive 06: runc vs crun
- Part 8: Container Internals Deep Dive 07: Rootless Containers with Podman
- Part 9: Container Internals Deep Dive 08: Kata Containers
- Part 10: Container Internals Deep Dive 09: Firecracker microVM
Series: 5/10. In part 03 we covered networking and CNI. Now we go deeper into containerd.
containerd is a core container runtime component used directly by Kubernetes (via CRI plugins) and indirectly by Docker.
High-level architecture #
- content store: blob storage for image layers
- metadata store: object references and lifecycle metadata
- snapshotters: provide mountable filesystem views (overlayfs, stargz, etc.)
- runtime shims: process supervisors between containerd and OCI runtime
- task service: create/start/kill process lifecycle
Lifecycle flow (simplified) #
- Pull image -> store blobs in content store.
- Unpack image -> snapshotter prepares rootfs.
- Create task -> shim starts OCI runtime.
- Start task -> process runs with configured isolation.
- Collect events, logs, exits via shim and containerd APIs.
Useful ctr commands
#
sudo ctr images ls
sudo ctr containers ls
sudo ctr tasks ls
sudo ctr snapshots ls
For Kubernetes nodes, crictl is usually better than raw ctr for day-2 ops.
Why shims exist #
Shims decouple container processes from the containerd daemon lifecycle. If containerd restarts, running containers can continue, and reconnect happens cleanly.
Tuning areas teams often miss #
- Snapshotter choice (performance vs compatibility).
- Garbage collection policies.
- Registry mirror configuration for pull resilience.
- RuntimeClass strategy for mixed workload security tiers.
Takeaway #
Treat containerd as a platform component, not a black box. Understanding its stores and shims pays off during incidents.