Docker Architecture (Docker Engine, Daemon, CLI, REST API)
Map how the CLI talks to the daemon via REST and how the engine orchestrates containers.
In plain words
The command you type asks a daemon for work, the daemon delegates the job, and runc finally starts the container process.
Think of it like…
A receptionist (CLI) records a request, a site manager (dockerd) plans the job, a contractor (containerd) holds the work item, and a specialist (runc) performs the kernel setup.
Where you’ve seen it
In practice, DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}} is the concrete move for this job: map how the CLI talks to the daemon via REST and how the engine orchestrates containers. The release is not accepted until curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker confirms the result.
Words you’ll hear
- Daemon
- The implementation control in
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}for map how the CLI talks to the daemon via REST and how the engine orchestrates containers. - CLI
- The result to observe with
curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker, rather than infer from a successful command alone. - REST API
- The production boundary exposed when debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.
Visual diagram
Theory & deep dive
Daemon control path
The concrete mechanism is DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}. The observable result is curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker; if those disagree, inspect the runtime evidence before changing unrelated settings.
Map how the CLI talks to the daemon via REST and how the engine orchestrates containers. Keep Daemon, CLI and REST API in the same deployment record so the intent and the observed state cannot drift apart.
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}
curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker, not with command success alone.REST API failure boundary
Most mysterious Docker failures become clear once the boundary is known: a client problem, API/daemon failure, containerd task problem, or app process exit. The daemon socket itself is privileged because anyone allowed to speak to it can usually control the host. The narrow failure to design for is debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.
Accept this compromise explicitly: A local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk. The controlled check-curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker-also identifies the point where a different design is safer.
Exercise this failure safely: debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: Most mysterious Docker failures become clear once the boundary is known: a client problem, API/daemon failure, containerd task problem, or app process exit. The daemon socket itself is privileged because anyone allowed to speak to it can usually control the host.
- Intent
- Daemon
When to use it & trade-offs
What it is
The Docker CLI serializes a request and sends it to dockerd over a Unix socket or TCP endpoint. The daemon delegates image and snapshot management plus lifecycle supervision to containerd, which asks an OCI runtime such as runc to create the isolated process.
Why it matters: Most mysterious Docker failures become clear once the boundary is known: a client problem, API/daemon failure, containerd task problem, or app process exit. The daemon socket itself is privileged because anyone allowed to speak to it can usually control the host.
When to reach for it
- The fit is strongest for this job: map how the CLI talks to the daemon via REST and how the engine orchestrates containers. Pair it with
curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status dockerin the runbook. - Production Daemon changes should make CLI observable through
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}, rather than trusting the runtime default. - Keep a rollback example for the case where debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.
When to avoid or be careful
- Do not accept command success while the system can still fail by debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.
- Avoid erasing REST API protection merely to dodge this cost: “A local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk”.
- Do not replace the evidence path-
curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker-with a screenshot or a mutable tag.
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}: practical choices
Strengths: The Docker CLI serializes a request and sends it to dockerd over a Unix socket or TCP endpoint. The daemon delegates image and snapshot management plus lifecycle supervision to containerd, which asks an OCI runtime such as runc to create the isolated process.
Watch out: A local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk.
Strengths: It can begin with DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}} and fewer surrounding controls.
Watch out: It silently accepts debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container, which makes the result hard to reproduce after promotion.
Strengths: Most mysterious Docker failures become clear once the boundary is known: a client problem, API/daemon failure, containerd task problem, or app process exit. The daemon socket itself is privileged because anyone allowed to speak to it can usually control the host.
Watch out: The platform adds an ownership and debugging layer; retain curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker as the direct check.
Interview signals & numbers to know
When this topic comes up
- DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}
- curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker
- Failure signature: debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container
- Trade-off: A local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk.
Benchmarks & rules of thumb
- 1 CLI request
- travels over the Docker HTTP API
- 2 lifecycle managers
- dockerd plus containerd in the common stack
- /_ping
- minimal daemon health endpoint
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}as proof and skippingcurl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker. - Debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container
- Optimizing Daemon without accepting that a local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk.
Likely interviewer follow-ups
- Why does
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}address Daemon here rather than through application code? - How would you distinguish healthy CLI from the failure “debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container” using
curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker? - When would this trade-off-“A local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk”-justify a different REST API design?
DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}-and one proof-curl --unix-socket /var/run/docker.sock http://localhost/_ping and inspect the same path in systemctl status docker. Then name the boundary: debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Docker Architecture (Docker Engine, Daemon, CLI, REST API) with generative AI interview Q&A and hands-on practice.