In this lesson, you will learn how the Docker daemon avoids getting bogged down by container execution by delegating the heavy lifting to containerd.
Why the Daemon Needs Help
Previously, we discussed the Docker daemon (dockerd) as the central brain that listens to your CLI commands via the API. In the early days of Docker, the daemon handled everything: managing images, building files, interacting with the network, and the low-level, high-stakes work of actually starting and supervising processes.
However, if the daemon is responsible for managing both the user's API requests and the nitty-gritty of container lifecycles, a single bug in the process management code could crash the entire Docker engine. To improve stability, Docker introduced a modular architecture that separates "high-level" management from "low-level" execution.
The Role of Containerd
containerd is a lightweight, specialized runtime that sits beneath the Docker daemon. Think of it as a professional foreman. When you run docker run, the daemon doesn't start the container itself. Instead, it sends a request to containerd: "Please start a container using this image and these namespace configurations."
Because containerd is decoupled, it performs the specific, difficult tasks of:
- Pulling image layers and preparing the filesystem.
- Executing the runtime to spawn the container process.
- Supervising the lifecycle of the container.
If the Docker daemon needs to be restarted for an update, the containerd process can keep your containers running in the background. This "decoupling" ensures that the core container processes remain isolated from the management layer.
Visualizing the Hierarchy
The flow of execution looks like this:
[User CLI] -> [Docker Daemon] -> [containerd] -> [runc (the executor)]
By offloading the execution logic to containerd, Docker becomes a much more stable and reliable platform. The daemon focuses on being the "manager" (talking to you), while containerd focuses on being the "executor" (talking to the operating system kernel).
Key Takeaway: Decoupling execution allows the Docker daemon to focus on API management while containerd provides a stable, independent layer for running and supervising container processes.