Week 9 - containerd Architecture¶
9.1 Conceptual Core¶
containerdis a container daemon that manages: image pull/push, content storage, layered snapshotters, runtime invocation (via OCI-spec runtimes likerunc/crun), task/process management.- It is not a monolithic daemon. Plugins (snapshotter, runtime, content store) are pluggable.
containerdis whatdockerdactually calls underneath; it is also the default runtime daemon in Kubernetes since 1.24.
9.2 Mechanical Detail¶
- Architecture (read
containerd/containerd/docs/architecture.md): - Content store-content-addressed blob storage.
- Image store-refs and image metadata.
- Snapshotters-
overlayfs,btrfs,zfs,stargz,devmapper. Pluggable. - Runtime plugin-invokes OCI runtimes via the
shimmodel (one shim process per container, decouples container lifecycle from daemon restart). - Tasks API-manage processes inside containers.
- Events API-pub/sub for lifecycle events.
- The
ctrCLI is a debugging tool, not a user-facing CLI. For users:nerdctl(Docker-compatible),crictl(CRI-level), or higher-level (Kubernetes, Buildah). - The shim (
containerd-shim-runc-v2) keeps the container alive acrosscontainerddaemon restarts. Each container has its own shim.
9.3 Lab-"containerd Without Kubernetes"¶
- Install
containerdandnerdctl. Configure/etc/containerd/config.toml. - Pull, run, exec, kill containers entirely via
nerdctl. Confirmdockerdis not running. - Enable the
stargz-snapshotter. Pull a large image with eStargz layers. Measure first-run startup time vs cold pull. - Use
ctrto inspect tasks, snapshots, and content blobs at the daemon level.
9.4 Hardening Drill¶
- Configure
containerdto use a custom seccomp profile and AppArmor (or SELinux) profile by default. Updateconfig.toml's[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]section.
9.5 Production Readiness Slice¶
- Wire
containerdmetrics to Prometheus (metrics.addressin config). Plot container start latency, image pull bytes, snapshotter ops/sec.