Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 3/ 160
01. Containerization & Docker Fundamentals

Docker Architecture (Docker Engine, Daemon, CLI, REST API)

Map how the CLI talks to the daemon via REST and how the engine orchestrates containers.

BeginnerDaemon · CLI3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Concrete Daemon setup

DOCKER_HOST=unix:///var/run/docker.sock docker version && docker info --format {{.ServerVersion}}

Key takeaway: Prove CLI with 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.

Deliberate failure test

Exercise this failure safely: debugging a stopped dockerd only from the application log, or mounting the daemon socket into an untrusted container.

Key takeaway: A local Unix socket is simple and fast, while a remote daemon adds network and certificate-management risk.

How it works, step by step

Step 1 of 4
Design

1. 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.

The command you type asks a daemon for work, the daemon delegates the job, and runc finally starts the container process.
Key numbers at this step
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 docker in 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

Explicit Daemon
Best for: Map how the CLI talks to the daemon via REST and how the engine orchestrates containers, with a reviewed runbook.

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.

Ambient default
Best for: Short-lived CLI experiments with low blast radius.

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.

Managed REST API
Best for: Teams that centralize REST API policy across many workloads.

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 skipping curl --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?
Interview tip: Give one concrete operation-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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
History & Evolution of Linux Containers (LXC, Docker, OCI)
Next topic
containerd, runc & Open Container Initiative (OCI) Standards