What You'll Learn
Beginner
- The three main components of Docker's architecture
- How the client, daemon, and registry interact
- What happens when you type
docker run - Why Docker uses a client-server architecture
The Three Components
1. Docker Client (docker)
The Docker client is the command-line tool you type commands into. It's the user-facing interface.
$ docker run ubuntu
docker: the client CLI
The client doesn't do any real work — it sends commands to the daemon via a REST API. It's the "waiter" that takes your order and passes it to the kitchen.
2. Docker Daemon (dockerd)
The Docker daemon (dockerd) is the background service that does all the actual work:
- Builds images
- Pulls and pushes images from/to registries
- Creates and manages containers
- Manages networks and volumes
The daemon runs as a background process (usually as root) and listens for API requests from the client.
3. Docker Registry
A registry is a storage service for Docker images. The most common is Docker Hub (hub.docker.com), but you can also use:
- Private registries (self-hosted or cloud-managed)
- Cloud provider registries (AWS ECR, Google GCR, Azure ACR)
- GitHub Container Registry (ghcr.io)
What Happens When You Run docker run ubuntu
docker run ubuntu in the terminal.ubuntu image exists locally.docker run — client to daemon to registry and backClient-Server Communication
The client and daemon communicate via a REST API over a Unix socket (on Linux) or a named pipe (on Windows). By default:
# Linux/macOS
/var/run/docker.sock
# Windows
//./pipe/docker_engine
The client can also connect to a remote daemon over TCP (useful for CI/CD or managing remote Docker hosts):
DOCKER_HOST=tcp://remote-server:2376 docker ps
Docker Hub — The Default Registry
Docker Hub (hub.docker.com) is the default public registry. When you run docker pull ubuntu, Docker pulls from docker.io/library/ubuntu.
Official vs community images
| Type | Example | Description |
|---|---|---|
| Official images | ubuntu, nginx, postgres | Curated by Docker, Inc. No namespace prefix. |
| User images | myuser/myapp | Uploaded by individual users. Has username prefix. |
| Verified publishers | microsoft/dotnet | Verified by Docker as official from the vendor. |
Other Docker Components
Beyond the three main components, Docker includes:
| Component | Purpose |
|---|---|
containerd | Container runtime — manages container lifecycle (Docker uses it internally) |
runc | Low-level container runtime — creates and runs containers per OCI spec |
docker buildx | Extended build capabilities (multi-platform, advanced caching) |
docker compose | Multi-container orchestration (covered in Module 6) |
Common Mistakes
- Confusing client and daemon.
docker(the CLI) is just a client.dockerd(the daemon) does the work. Ifdocker psfails, the daemon might not be running. - Thinking Docker Hub is the only registry. Many organizations use private registries (AWS ECR, Harbor, GitHub Container Registry) for security and performance.
- Exposing the Docker socket. Mounting
/var/run/docker.sockinto a container gives that container root access to the host. Only do this for trusted images. - Forgetting the daemon runs as root. The Docker daemon needs root privileges. This is a security consideration in multi-tenant environments.
Practical Exercise (5 minutes)
docker version — see separate client and daemon versionsdocker info — see daemon details (storage driver, registry, containers running)docker pull alpine — explicitly pull an image without running itdocker images — see the image in your local cachedocker run alpine echo "hello" — notice it doesn't need to pull (already cached)Mini Challenge
Run docker info and find: (1) what storage driver your Docker uses, (2) how many containers are running, (3) the default registry configured. Understanding docker info output is essential for troubleshooting.
Key Takeaways
- Docker has three main components: client (CLI), daemon (dockerd), and registry (image store).
- The client sends commands; the daemon does the work; the registry stores images.
docker run= client sends API request → daemon checks cache → pulls if needed → creates container → starts it.- Docker Hub is the default registry, but you can use private or cloud registries too.
- The Docker socket gives root access — never expose it unauthenticated.
Today: You learned the Docker architecture: client, daemon, registry.
Next: Lesson 05 shows how to install Docker on macOS, Windows, and Linux.
FAQ
Can the client and daemon be on different machines?
Yes. Set DOCKER_HOST to point the client at a remote daemon. This is common in CI/CD pipelines where the build runs on one machine and Docker runs on another. Use TLS for security.
What's the difference between Docker Engine and Docker Desktop?
Docker Engine is the open-source daemon + CLI that runs on Linux. Docker Desktop is a commercial product for macOS and Windows that includes Docker Engine inside a Linux VM, plus a GUI and additional tools. On Linux, you typically install Docker Engine directly.
Comments
Comments
Post a Comment