Docker Architecture: Engine, Daemon, CLI, and Registry
Docker architecture explained: the CLI, dockerd, containerd, runc and registries, how they talk to each other, and why the Docker socket is risky.
docker CLI is only a client that sends requests to a long-running daemon, dockerd, over a REST API. The daemon builds and manages images, networks and volumes, then delegates the actual running of containers to containerd and the low-level runtime runc. Images move between machines through registries such as Docker Hub, which store them by name, tag and content digest. Knowing which component does what explains most “Cannot connect to the Docker daemon” errors, why Kubernetes no longer needs Docker to run your images, and why access to the Docker socket is equivalent to root on the host.
The first Docker error most developers meet is Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? The CLI is installed, the command is right, and still nothing works. The message makes sense once you know that the docker command does almost nothing itself. It is a thin client, and the work happens somewhere else.
Docker architecture describes the pieces that cooperate when you run docker run nginx: the CLI that parses your command, the Docker Engine daemon that holds state and orchestrates work, the container runtimes that create isolated processes using the kernel features described in Docker vs. virtual machines, and the registry that stores and distributes images.
The request path of docker run
docker CLI
| REST API over /var/run/docker.sock (or TCP/SSH)
v
dockerd (Docker Engine: images, networks, volumes, build, API)
| gRPC
v
containerd (container lifecycle, image storage and snapshots)
|
v
containerd-shim (one per container, keeps it running if containerd restarts)
|
v
runc (creates namespaces and cgroups, starts the process, then exits)
|
v
your process, running directly on the host kernel
Here is what happens when you type docker run -d -p 8080:80 nginx:
- The CLI turns the command into API calls and sends them to the daemon.
dockerdchecks whether thenginx:latestimage exists locally. If not, it pulls it from the default registry, Docker Hub.- The daemon creates the container’s configuration: its writable layer, network endpoint, port mapping and mounts.
- It asks containerd to start the container. containerd starts a shim process, which calls runc.
- runc sets up namespaces and cgroups, starts the nginx process inside them, and exits. The shim stays as the container’s parent, collecting its exit status and keeping its standard streams open.
- The CLI prints the container ID and returns.
The components
The CLI
docker is a client for the Engine API. Everything it does can also be done with curl against the API, which is exactly what tools like Portainer, IDE plugins and CI agents do. The CLI talks to the local Unix socket by default, but the DOCKER_HOST environment variable or a Docker context points it elsewhere:
docker context create build-server --docker "host=ssh://deploy@build01.internal"
docker context use build-server
docker ps # lists containers on build01, not your laptop
docker context use default
The daemon: dockerd
The Docker Engine daemon owns the high-level objects: images, containers, networks, volumes, build and the API. It is configured through /etc/docker/daemon.json for things like log drivers, registry mirrors, storage driver and default address pools. It runs as root on a standard installation, which is important for security, as described below. Docker Engine 23.0, now in release candidates and due out in the coming weeks, makes BuildKit the default builder on Linux, so docker build will use the faster, cache-efficient build engine that previously needed DOCKER_BUILDKIT=1.
containerd and runc
containerd is a container runtime that Docker donated to the Cloud Native Computing Foundation in 2017. It manages container lifecycles and image storage, and it is used directly by Kubernetes and many cloud platforms. runc is the reference implementation of the OCI runtime specification: a small binary that creates the container from a configuration file and exits. Because of this layering, you can restart dockerd for an upgrade and, with live restore enabled, running containers keep running.
The registry
A registry stores images and serves them over an HTTP API defined by the OCI distribution specification. Docker Hub is the default; others include GitHub Container Registry (ghcr.io), Amazon ECR, Google Artifact Registry, Azure Container Registry and self-hosted options such as Harbor.
Reading an image reference
ghcr.io/acme/billing-api:1.4.2@sha256:9f86d081884c7d65...
|______| |________| |_____| |______________________|
registry namespace/repo tag digest
- Registry: omitted, it defaults to
docker.io. - Repository: official images on Docker Hub have the implicit namespace
library, songinxmeansdocker.io/library/nginx. - Tag: a movable label. Omitted, it defaults to
latest, which is just a tag name, not a promise that the image is the newest. - Digest: the SHA-256 hash of the image manifest. It is immutable; pulling by digest always gives exactly the same image.
Tags can be moved to point at a new image at any time, which is convenient for nginx:1.23 picking up patch releases and dangerous for production deployments that need to be reproducible. Pin production deployments by digest, or at least by a specific version tag you control.
Docker Hub also applies pull rate limits: 100 pulls per six hours for anonymous users and 200 for authenticated free accounts, counted per IP or per account. Busy CI runners behind a shared IP hit them regularly. Authenticate in CI, use a registry mirror, or copy base images into your own registry.
Standards: why Docker images run without Docker
The Open Container Initiative (OCI) defines three specifications: the image format, the runtime behavior and the distribution API. Images built with Docker are OCI images, so they run on containerd, CRI-O, Podman and every major cloud service. This is why Kubernetes could remove its Docker integration, the “dockershim”, in version 1.24 last year without breaking anyone’s images: the cluster talks to containerd or CRI-O directly, and the images are the same.
It also means Docker is one choice among several. Podman runs containers without a central daemon and without root, and Buildah and Kaniko build images without a daemon, which is useful in locked-down CI environments.
The Docker socket is root access
Anyone who can send requests to /var/run/docker.sock can tell the root-owned daemon to start a container that mounts the host’s entire filesystem, or runs privileged. In practice that equals root on the host. Two consequences:
- Adding a user to the
dockergroup is granting them root. Do it deliberately. - Mounting the socket into a container, a common pattern for CI agents and dashboards, gives that container control of the host. Prefer alternatives such as rootless Docker, a dedicated build VM, or daemonless builders.
Never expose the daemon on TCP without TLS client authentication. Unauthenticated Docker APIs exposed on port 2375 are routinely found and used to run cryptocurrency miners.
Docker Desktop vs Docker Engine
On Linux servers you install Docker Engine, the open-source daemon and CLI. Docker Desktop is a separate product for macOS, Windows and Linux desktops that bundles the engine inside a managed VM with a GUI, Compose, Kubernetes and extensions. Docker Desktop requires a paid subscription for use at companies with more than 250 employees or more than 10 million US dollars in annual revenue, so check before rolling it out across a team. Free alternatives on macOS include Colima and Rancher Desktop.
Frequently Asked Questions
What is the difference between Docker Engine and the docker CLI?
Docker Engine is the daemon, dockerd, that builds images and manages containers, networks and volumes. The docker CLI is a client that sends requests to the Engine’s API. The CLI can talk to a local daemon over a Unix socket or to a remote one over SSH or TLS.
What do containerd and runc do?
containerd manages container lifecycles and image storage on behalf of dockerd. runc is the low-level OCI runtime that actually creates the namespaces and cgroups and starts the container process, then exits.
How do I fix “Cannot connect to the Docker daemon”?
Check that the daemon is running, for example with systemctl status docker on Linux or by starting Docker Desktop. Check that your user can access the socket, usually by membership of the docker group, and that DOCKER_HOST or the current docker context is not pointing at an unreachable host.
Does Kubernetes still run Docker images?
Yes. Kubernetes removed its built-in Docker integration in version 1.24, but images built with Docker follow the OCI image specification and run unchanged on containerd and CRI-O, the runtimes Kubernetes uses.
A client, a daemon and a chain of runtimes
Once you see Docker as a CLI talking to a daemon, which delegates to containerd and runc, and pulls from registries by tag or digest, most of its behavior stops being mysterious. Connection errors point to the socket or context, pinned digests explain reproducible deploys, and the root-owned daemon explains why the Docker socket deserves the same care as an SSH key to production. The official documentation is worth keeping open: the Docker architecture overview and the Open Container Initiative. Related reading on this site: images, containers and layers and choosing a base image.
Originally posted on 25 January 2023 and post last modified on 25 January 2023