Docker Tutorial 0/48 lessons ~6 min read Lesson 4

    Docker Architecture

    Docker uses a client-server architecture.

    Course progress0%
    Focus
    14 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Docker uses a client-server architecture. The docker CLI you type into is a thin client that sends REST requests over a Unix socket to the Docker daemon (dockerd), which does the real work — building images, running containers, managing networks and volumes.

    Purpose of this lesson

    This lesson teaches Docker Architecture as an engineering decision: what problem it solves, when to use it, how to implement it safely, and what signals tell you it is failing.

    Understanding the topic

    Use this as foundation knowledge before moving into image builds, Compose stacks, CI/CD, and production hardening. The goal is to understand the runtime model rather than memorize commands.

    Core concepts to understand:

    • Client (docker CLI) → Daemon (dockerd) → containerdrunc → kernel.
    • Daemon is a long-running background process; restart it if it hangs.
    • Registry stores images (Docker Hub, GHCR, ECR, Artifactory, …).
    • Remote access: DOCKER_HOST=tcp://… lets one client manage many daemons.

    Visual explanation

    Architecture or command flow to keep in mind:

    bash
    ┌──────────┐ REST ┌────────────┐
    │ docker │ ───────▶ │ dockerd │
    (CLI) │ │ (daemon)
    └──────────┘ └─────┬──────┘
    ┌─────────────┼───────────────┐
    ▼ ▼ ▼
    ┌─────────┐ ┌──────────┐ ┌────────────┐
    │ Images │ │Containers│ │ Networks / │
    (local) │ │ (running)│ │ Volumes │
    └────┬────┘ └──────────┘ └────────────┘
    ┌─────────┐
    │Registry │ ← docker pull / push
    (Hub)
    └─────────┘

    Step-by-step explanation

    1. Run the command or manifest exactly once on a clean Docker host and read the output carefully.
    2. Inspect the object Docker created: image, container, network, volume, port mapping, process, or registry tag.
    3. Break one realistic assumption such as a missing port, bad tag, stopped daemon, wrong network, or deleted volume.
    4. Use docker ps, logs, inspect, stats, and system df to locate the failure.
    5. Write the final command or configuration into a repeatable script, Compose file, or CI job.

    Informative example

    Use the example below as a working baseline, then verify the runtime behavior instead of assuming the command or file is correct.

    bash
    ┌──────────┐ REST ┌────────────┐
    │ docker │ ───────▶ │ dockerd │
    (CLI) │ │ (daemon)
    └──────────┘ └─────┬──────┘
    ┌─────────────┼───────────────┐
    ▼ ▼ ▼
    ┌─────────┐ ┌──────────┐ ┌────────────┐
    │ Images │ │Containers│ │ Networks / │
    (local) │ │ (running)│ │ Volumes │
    └────┬────┘ └──────────┘ └────────────┘
    ┌─────────┐
    │Registry │ ← docker pull / push
    (Hub)
    └─────────┘

    A production-minded check usually includes docker ps, docker logs, docker inspect, and one validation from outside the container such as curl, a database connection, or a registry pull.

    bash
    # Verification loop for Docker Architecture
    docker ps -a
    docker logs --tail=100 <container-name>
    docker inspect <container-or-image-name>
    docker system df

    Real-world use

    On a CI runner, the same client can drive a remote daemon, which is how GitHub Actions builds images on dedicated build hosts while your laptop stays cool.

    Enterprise use cases

    In a mature engineering organization, Docker Architecture is documented as a repeatable pattern with approved base images, ownership labels, CI checks, security expectations, rollback notes, and troubleshooting commands. The difference between a tutorial and production practice is that every container decision must be observable, reviewable, and reversible.

    Best practices

    • Never expose dockerd on TCP without TLS — full root access to the host.
    • Use rootless mode (dockerd-rootless-setuptool.sh) to run the daemon as non-root.

    Debugging tips

    • Read logs before restarting; a restart often removes the timing context you need for root cause analysis.
    • Use docker inspect to compare configured state with actual runtime state.
    • Check daemon health, disk usage, image tags, exit code, and port mappings before blaming application code.

    Optimization strategies

    • Prefer explicit names, labels, tags, and networks so cleanup and debugging stay predictable.
    • Pin versions for repeatability, then update intentionally through a scheduled base-image refresh.
    • Use docker system df and targeted prune commands to control local and CI disk growth.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    3 questions
    1QuestionIs Docker a client or server?+

    Answer

    A strong answer for Docker Architecture should define the concept, explain the Docker component involved, give one real use case, and name at least one failure mode plus the command you would use to investigate it.
    2QuestionWhat is containerd and why was it split out of Docker?+

    Answer

    A strong answer for Docker Architecture should define the concept, explain the Docker component involved, give one real use case, and name at least one failure mode plus the command you would use to investigate it.
    3QuestionHow does the CLI talk to the daemon?+

    Answer

    A strong answer for Docker Architecture should define the concept, explain the Docker component involved, give one real use case, and name at least one failure mode plus the command you would use to investigate it.

    Hands-on exercise

    Create a small lab for Docker Architecture: run the example, inspect the created Docker object, intentionally introduce one mistake, and record the command that reveals the failure. The goal is not just to make the happy path work; it is to build operational reflexes.

    bash
    # Hands-on lab scaffold
    mkdir -p docker-docker-architecture-lab
    cd docker-docker-architecture-lab
    # Add the Dockerfile, compose.yml, or command from this lesson.
    # Then run one happy-path test and one broken-path test.
    docker version
    docker info
    docker system df

    Summary

    Docker Architecture matters because Docker is not only a packaging tool; it is a runtime, build, networking, storage, and delivery workflow. Treat each lesson as a production habit: make it repeatable, inspectable, secure, and easy to debug.

    Ready to mark this lesson complete?Track your journey across the entire course.