Skybinary

View Categories

2. Docker Architecture

2 min read

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:

  1. Images
    • A read-only template used to create containers.
    • Built from a Dockerfile containing instructions.
    • Example: ubuntu, nginx, python:3.9.
    • Command: docker images docker build -t myapp:1.0 .
  2. 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
  3. 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
  4. 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 run or docker build.
  • Server (Daemon): Executes those commands.
  • REST API: The communication layer between the Client and Daemon.

Example Workflow:

  1. User runs a command → docker run nginx.
  2. Docker Client sends the request via REST API to the Daemon.
  3. Daemon checks if the image is available locally.
  4. If not, it pulls the image from the Docker Registry.
  5. 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:

  1. Build:
    • Create Docker images from source code using a Dockerfile.
    • Example: docker build -t myapp:1.0 .
  2. Ship:
    • Push images to a registry (Docker Hub or private registry).
    • Example: docker push username/myapp:1.0
  3. 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 #

  1. Check Docker version docker version Displays client and server (daemon) version details.
  2. View Docker system information docker info Shows detailed info about images, containers, storage drivers, and system configuration.

Summary #

ComponentFunction
Docker DaemonManages Docker objects and runs in the background
Docker ClientSends commands to the daemon via REST API
Docker RegistryStores and distributes Docker images
Docker ObjectsImages, Containers, Volumes, Networks
Architecture TypeClient–Server
WorkflowBuild → Ship → Run

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top