The Docker architecture: client, daemon and runtimes

Beginner · 14 min

What runs when you type docker run: the CLI, the Engine API, dockerd, containerd, the shim and runc, and why the work is split across five programs.

Before thisContainers vs virtual machines

KodeKloud · 14 min

The Docker architecture: client, daemon and runtimes

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by KodeKloudReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The docker command is only a client. It sends HTTP requests to the Engine API, by default over the Unix socket /run/docker.sock.
  • dockerd owns the Docker objects: images, containers, networks, volumes and builds. It hands the running of containers to containerd.
  • containerd manages container lifecycles and, since Engine 29 on fresh installs, images too. It starts one shim per container rather than running containers itself.
  • runc is the low-level OCI runtime. It sets up namespaces, cgroups and the root filesystem, starts the process and exits.
  • The shim stays behind as the container's parent, holding its stdio and exit status, so dockerd and containerd can restart without killing containers.
  • Because the client only speaks HTTP, the same CLI can drive a local daemon, a Docker Desktop VM or a remote host by changing DOCKER_HOST or the context.

One command, five programs

You type docker run -d nginx and a web server is running a second later. It feels like one program did that. It wasn’t. On a Linux host, at least five programs took part, and when something breaks, the error message names one of them. “Cannot connect to the Docker daemon”, “OCI runtime create failed” and “failed to create shim task” come from three different layers. Knowing the layers tells you where to look.

The chain

docker (CLI)
  │  HTTP, Engine API v1.57, over /run/docker.sock
  ▼
dockerd                images, containers, networks, volumes, builds (BuildKit)
  │  gRPC, over /run/containerd/containerd.sock
  ▼
containerd             container lifecycle, image content and snapshots
  │  starts one shim per container, then talks ttRPC to it
  ▼
containerd-shim-runc-v2   stays as the container's parent
  │  runs
  ▼
runc                   creates namespaces and cgroups, starts the process, exits
  ▼
your process (PID 1 inside the container)

Think of a restaurant. The CLI is the customer placing an order. dockerd is the front of house, which knows the menu and the tables. containerd is the kitchen manager. runc is the cook who plates the dish and moves on. The shim is the waiter who stays with that table for the whole meal.

The client and the API

docker is a client and nothing more. Each command is one or more HTTP calls to the Engine API. Per the docker run reference, docker run becomes POST /containers/create, a pull if the image is missing, POST /containers/{id}/start, and an attach when you pass -it. The current API spec is version 1.57, with 98 paths. Engine 29 dropped support for clients older than API 1.44 (Docker 25).

Because it’s plain HTTP, you could do the same with curl, from the Engine API docs (not run here, as there is no daemon on this machine):

curl --unix-socket /run/docker.sock http://localhost/v1.57/containers/json

The socket is also why DOCKER_HOST=ssh://admin@build-box or a docker context can point the same CLI at another machine, and why Docker Desktop works: the CLI on your Mac talks to a daemon inside a Linux VM.

dockerd and containerd

dockerd is the Docker-specific part. It understands Docker’s objects: it sets up bridge networks and port publishing, manages volumes, keeps container configuration, runs builds through its embedded BuildKit, and serves the API. It doesn’t create containers itself.

containerd is a separate daemon, donated by Docker to the CNCF in 2017, and the same one Kubernetes nodes use. It manages container lifecycles and, with the containerd image store that became the default on fresh Engine 29 installs, stores images as well. Upgraded hosts keep the older overlay2 store until you switch.

The packages show the split. I downloaded Docker’s Ubuntu 26.04 packages from download.docker.com and listed their binaries:

docker-ce-cli 29.10.1   /usr/bin/docker
docker-ce 29.10.1       /usr/bin/dockerd  /usr/bin/docker-proxy  /usr/libexec/docker/docker-init
containerd.io 2.4.2     /usr/bin/containerd  /usr/bin/containerd-shim-runc-v2  /usr/bin/ctr  /usr/bin/runc

docker-proxy forwards published ports in some cases, and docker-init is the tiny init that docker run --init injects as PID 1. The bundled runc reports version v1.5.3. Engine 29.7 added an experimental mode that runs containerd inside the dockerd process, and since 29.8 dockerd falls back to that embedded containerd when no containerd is installed. With the standard packages, containerd is still its own service.

The shim and runc

runc implements the OCI runtime spec. Given a bundle (a root filesystem plus a config.json), it creates the namespaces and cgroup, pivots into the root filesystem, drops capabilities, applies seccomp and starts your process. Then it exits. It’s a command, not a daemon.

Something has to stay behind to hold the container’s stdin and stdout, wait for it to exit and record the exit code. That’s the shim. Per containerd’s runtime v2 docs, containerd launches the shim, the shim starts a long-lived process listening on its own socket and the launcher exits, so the shim isn’t containerd’s child. The systemd units back this up. From the packaged files:

# docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
KillMode=process
# containerd.service
ExecStart=/usr/bin/containerd
KillMode=process

KillMode=process tells systemd to stop only the daemon’s main process, not every process in its cgroup. Restart containerd and the shims and containers keep running. Add "live-restore": true to daemon.json and the same holds for dockerd restarts and upgrades.

Why the split matters

Each layer is replaceable because the boundaries are standards. Kubernetes drops dockerd and talks to containerd or CRI-O through the CRI. containerd can call crun, runsc (gVisor) or Kata instead of runc. nerdctl gives containerd a Docker-like CLI with no dockerd at all, which the alternatives lesson covers. The specs that make the swaps possible are the next lesson.

The socket is the other lesson. Whoever can write to /run/docker.sock can ask dockerd, running as root, to start a privileged container that mounts the host’s /. The packaged docker.socket unit sets it to 0660 root:docker, so membership of the docker group is root on that machine. The security group covers this.

About the video

The embed is all of KodeKloud’s “Docker vs Containerd: Understanding the Differences and Choosing the Right Containerization Tool”, May 2023, 14 minutes. Its chapters cover the history of containers (how Docker’s engine was split and containerd donated, and why Kubernetes added the CRI), what containerd is, and three command-line clients for it, ctr, nerdctl and crictl, then Docker against crictl. That history is exactly why there are five programs. It doesn’t show the shim, the Engine API or Engine 29’s changes, which this lesson adds. English was judged from the channel and its “English (US) original” audio track. The InvolveInInnovation video in deeper draws the full chain including the shim.

What was run: Docker’s Ubuntu 26.04 apt index was downloaded, and the docker-ce, docker-ce-cli and containerd.io packages were unpacked with ar and tar to list their binaries, read the systemd units and find the runc version string. The API version and path count come from the Engine API’s swagger.yaml. No daemon ran. The request flow is from the docker run reference and containerd’s runtime v2 docs, and the Engine 29 changes from its release notes, checked 2026-11-28.

Where this fits

Next, the three specs that let these pieces be swapped: the OCI standards.

Check yourself

  1. 01You run docker ps and get 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock'. Is the docker binary broken?

    Probably not. The CLI is fine but nothing is listening on the socket, so check whether dockerd is running (systemctl status docker) and whether you have permission to the socket.

  2. 02You restart containerd with systemctl. Why don't your running containers die?

    Each container's parent is its shim, not containerd. The systemd units also use KillMode=process, so only the daemon's main process is stopped and the shims and containers keep running.

  3. 03What does runc do after it has started your container's process?

    It exits. runc only creates and starts the container from an OCI bundle. The shim, not runc, stays around to wait on the process and report its exit code.

  4. 04Why can Kubernetes run images built with docker build without using Docker at all?

    Both use OCI images and an OCI runtime. Kubernetes talks to containerd or CRI-O through the CRI, and they pull the same images and call runc or crun, skipping dockerd entirely.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark