Docker Architecture #
Docker architecture follows a client-server model where the Docker Client interacts with the Docker Daemon (Server) through APIs.
This design allows developers to manage containers, images, networks, and volumes locally or remotely in a consistent way.
Docker Engine Components #
The Docker Engine is the core part of Docker responsible for creating and managing containers. It consists of the following components:
1. Docker Daemon (dockerd) #
- The Docker Daemon runs in the background on the host system.
- It listens for Docker API requests and manages Docker objects like containers, images, networks, and volumes.
- It performs all heavy operations like building images, starting containers, and handling communication between them.
- The daemon can communicate with other daemons to manage containers on remote systems (useful in cluster setups).
Example:
When you run:
docker run nginx
The Docker CLI sends a request to the Docker Daemon, which pulls the nginx image, creates a container, and starts it.
2. Docker Client #
- The Docker Client is the primary interface users interact with.
- It accepts commands from the terminal and communicates with the Docker Daemon using REST APIs.
- The client can interact with multiple daemons, either local or remote.
Common Example Commands:
docker ps # List running containers docker build . # Build an image docker stop app # Stop a running container
3. Docker Registry #
- The Docker Registry is a storage and distribution system for Docker images.
- It can be:
- Public Registry: Docker Hub (default registry)
- Private Registry: Used within organizations for secure image management
- When you run
docker pull ubuntu, Docker downloads the image from the registry. - When you run
docker push, your custom image is uploaded to the registry.
Example Commands:
docker pull nginx docker push username/myapp:latest
4. Docker Objects #
Docker works around four main objects that define its ecosystem:
- Images
- A read-only template used to create containers.
- Built from a
Dockerfilecontaining instructions. - Example:
ubuntu,nginx,python:3.9. - Command:
docker images docker build -t myapp:1.0 .
- Containers
- A running instance of a Docker image.
- Containers are isolated but can communicate through networks.
- You can start, stop, or remove them easily.
- Command:
docker run -d --name web nginx docker ps -a docker stop web
- Volumes
- Used for persistent storage so that container data isn’t lost when the container stops.
- Command:
docker volume create mydata docker run -v mydata:/data nginx
- Networks
- Allow containers to communicate securely with each other.
- Docker automatically creates a bridge network by default.
- Command:
docker network ls docker network create backend
Client-Server Architecture #
Docker uses a Client-Server architecture based on REST APIs.
- Client: Sends commands like
docker runordocker build. - Server (Daemon): Executes those commands.
- REST API: The communication layer between the Client and Daemon.
Example Workflow:
- User runs a command →
docker run nginx. - Docker Client sends the request via REST API to the Daemon.
- Daemon checks if the image is available locally.
- If not, it pulls the image from the Docker Registry.
- The Daemon creates and starts the container.
This process can happen locally or remotely if the daemon is running on another machine.
Docker Flow: Build → Ship → Run #
Docker simplifies software delivery with a three-stage lifecycle:
- Build:
- Create Docker images from source code using a
Dockerfile. - Example:
docker build -t myapp:1.0 .
- Create Docker images from source code using a
- Ship:
- Push images to a registry (Docker Hub or private registry).
- Example:
docker push username/myapp:1.0
- Run:
- Pull the image from the registry and run it as a container on any environment.
- Example:
docker pull username/myapp:1.0 docker run -d -p 80:80 username/myapp:1.0
This Build → Ship → Run process ensures that applications run consistently across all systems — a key principle in DevOps automation.
Commands to Practice #
- Check Docker version
docker versionDisplays client and server (daemon) version details. - View Docker system information
docker infoShows detailed info about images, containers, storage drivers, and system configuration.
Summary #
| Component | Function |
|---|---|
| Docker Daemon | Manages Docker objects and runs in the background |
| Docker Client | Sends commands to the daemon via REST API |
| Docker Registry | Stores and distributes Docker images |
| Docker Objects | Images, Containers, Volumes, Networks |
| Architecture Type | Client–Server |
| Workflow | Build → Ship → Run |