Chapter 03 • Core Foundations

Docker Architecture & Engine Internals

Many developers view Docker as a single monolithic executable. Under the hood, Docker Engine is a decoupled, multi-tiered distributed system comprising the Docker CLI, the dockerd management daemon, the containerd runtime supervisor, and the low-level runc OCI container executor.

1. The Multi-Tiered Runtime Architecture

When Docker originally launched in 2013, the dockerd daemon executed everything. Today, following the Open Container Initiative (OCI) standardization, the architecture is cleanly modularized:

ComponentLayerResponsibilityProcess Life Cycle
Docker CLI (docker)User InterfaceTranslates user terminal commands into HTTP/REST API calls. Stateless client.Runs per command and terminates.
Docker Daemon (dockerd)Orchestration & APIExposes the REST API, manages storage volumes, bridge networks, image builds, and authentication.Persistent systemd background service.
containerdSupervisor RuntimeManages image layer distribution (pull/push), snapshot storage, and supervises container execution.Persistent daemon (also used directly by Kubernetes via CRI).
containerd-shimProcess DecouplerKeeps container STDIN/STDOUT FIFO file descriptors open and reports exit codes without daemon dependency.One tiny process per active running container.
runcOCI Low-Level RuntimeDirectly talks to the Linux kernel to create namespaces, mount root filesystems, configure cgroups, and call execve.Ephemeral: spawns the container process and exits immediately.

2. Why containerd-shim is a Game-Changer

In legacy Docker versions, if the dockerd daemon crashed or required a software update, all running containers on that host server instantly died.

Modern Docker Engine solves this via containerd-shim. When you launch a container:

  1. containerd requests runc to construct the container process.
  2. containerd-shim attaches to the container's standard I/O pipes.
  3. runc hands over ownership of the process to containerd-shim and exits.
Daemonless Live Restore: Because the container is parented by containerd-shim rather thandockerd, you can enable "live-restore": true in /etc/docker/daemon.json. This allows you to upgrade, restart, or crash the Docker daemon without dropping a single active HTTP connection or restarting containers!

3. The Docker Socket: /var/run/docker.sock

Communication between the Docker CLI and the daemon occurs over a local UNIX domain socket located at/var/run/docker.sock. The CLI sends standard HTTP 1.1 JSON requests over this socket:

# Query the Docker REST API directly using curl over the UNIX socket:
curl --unix-socket /var/run/docker.sock http://localhost/version

# List running containers directly via raw HTTP REST API:
curl --unix-socket /var/run/docker.sock http://localhost/containers/json
Critical Security Warning: Mounting /var/run/docker.sock inside an untrusted container is equivalent to granting unrestricted root access to the entire host machine. A malicious process inside the container can instruct the daemon to mount the host root directory (/) and compromise the server.

4. Storage Driver: The Overlay2 Filesystem

Docker constructs a container's unified root filesystem using the Overlay2 storage driver. Overlay2 merges multiple directory layers into a single combined view using four key directories inside/var/lib/docker/overlay2/:

lowerdir
Image Layers

Read-only base layers containing operating system binaries and dependencies.

upperdir
Container Layer

Writable layer holding all file modifications, creations, and deletions.

workdir
Staging Workdir

Internal scratchpad used by Linux kernel for atomic file operations.

merged
Mount Point

The unified view exposed to the container process as root (/).

Next Up: Essential Docker CLI Commands

Now that you understand the underlying engine architecture, learn how to manage container lifecycles using essential CLI operations.

Chapter 04: Essential Docker Commands →

Explore Related Tools

Hand-picked utilities and calculators related to this tool.

Related Tools