DEV Community

Haripriya Veluchamy
Haripriya Veluchamy

Posted on

Docker Architecture and Installation: Getting Started with Docker πŸ—οΈ

After understanding container basics, I figured it would be helpful to explain Docker's architecture and get you set up with Docker. This is part two of my Docker series where I'll break down how Docker actually works behind the scenes.

Docker Architecture: How It All Fits Together 🧩

To understand Docker, you need to understand its architecture. Docker uses a client-server architecture consisting of several components that work together to create and manage containers.

Client-Server Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     REST API      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Docker CLI  β”‚ ←───────────────→ β”‚  Docker Daemon  β”‚
β”‚ (Client)    β”‚                   β”‚  (Server)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                   β”‚
       β”‚                                   β”‚
       β”‚                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚                β”‚                  β”‚                β”‚
       β–Ό                β–Ό                  β–Ό                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Images    β”‚  β”‚  Containers β”‚  β”‚   Networks  β”‚  β”‚   Volumes   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

1. Docker Client (CLI)

The Docker client (docker) is the primary way users interact with Docker. When you run commands like docker run or docker build, you're using the Docker client. Key features:

  • Simple command-line interface
  • Can connect to local or remote Docker daemons
  • Handles user input and displays results
  • Communicates with the daemon via REST API

Example commands:

docker build -t my-app .
docker run my-app
docker ps
Enter fullscreen mode Exit fullscreen mode

2. Docker Daemon (Server)

The Docker daemon (dockerd) is a background service that manages Docker objects. It's the workhorse that:

  • Listens for Docker API requests
  • Manages Docker objects (images, containers, networks, volumes)
  • Communicates with other daemons
  • Executes container operations

The daemon runs on the host machine and does the heavy lifting of building, running, and distributing your Docker containers.

3. Docker Registry

Docker registries store Docker images. Docker Hub is a public registry anyone can use, and Docker is configured to look for images on Docker Hub by default.

  • Docker Hub: Public registry with thousands of images
  • Private registries: For storing proprietary images
  • Self-hosted registries: Run your own registry within your infrastructure

When you run docker pull or docker run, the required images are pulled from your configured registry. When you run docker push, your image is pushed to your configured registry.

# Pull an image from Docker Hub
docker pull nginx

# Push an image to Docker Hub
docker push username/my-app:1.0
Enter fullscreen mode Exit fullscreen mode

Docker Objects: The Building Blocks 🧱

Docker creates and uses various objects in the process of running containers:

1. Images

An image is a read-only template with instructions for creating a Docker container. Images:

  • Are built from a Dockerfile
  • Consist of multiple layers
  • Can be stored in registries
  • Are the foundation for containers
# List all images
docker images

# Remove an image
docker rmi image-id
Enter fullscreen mode Exit fullscreen mode

2. Containers

A container is a runnable instance of an image. You can:

  • Create, start, stop, move, or delete containers
  • Connect containers to networks
  • Attach storage to containers
  • Create a new image based on a container's current state
# List running containers
docker ps

# List all containers (including stopped)
docker ps -a
Enter fullscreen mode Exit fullscreen mode

3. Networks

Docker networks allow containers to communicate with each other and with the outside world we will see in future post

4. Volumes

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers we will se in future post

Docker Desktop vs. Docker Engine

Before we start, it's important to understand the difference between Docker Desktop and Docker Engine:

  • Docker Desktop: All-in-one application for Windows and Mac that includes:

    • Docker Engine
    • Docker CLI
    • Docker Compose
    • Kubernetes
    • GUI management interface
    • Integration with system services
  • Docker Engine: Core Docker technology that powers containers:

    • Lightweight installation
    • Command-line only (no GUI)
    • Typically used on Linux servers
    • What actually runs and manages containers

Installing Docker

The easiest way to install Docker is to visit the official Docker website and download the appropriate version

After installation, verify everything works:

docker --version
docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Post-Installation Steps

1. Run Docker without sudo (Linux)

By default, on Linux systems, you need sudo privileges to run Docker commands. To avoid this:

# Create the docker group if it doesn't exist
sudo groupadd docker

# Add your user to the docker group
sudo usermod -aG docker $USER

# Apply the changes (or log out and back in)
newgrp docker
Enter fullscreen mode Exit fullscreen mode

After these steps, you should be able to run Docker commands without sudo:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

⚠️ Security Note: Adding users to the docker group grants them privileges equivalent to root access. Only add trusted users.

2. Configure Docker Hub Access

If you plan to push images to Docker Hub:

docker login
# Enter your Docker Hub username and password
Enter fullscreen mode Exit fullscreen mode

Testing Your Docker Installation πŸ§ͺ

Let's make sure everything is working correctly with a few simple tests:

1. Check Docker Version

docker --version
Enter fullscreen mode Exit fullscreen mode

You should see output showing your Docker version, like:

Docker version 20.10.17, build 100c701
Enter fullscreen mode Exit fullscreen mode

2. View System Information

docker info
Enter fullscreen mode Exit fullscreen mode

This displays detailed information about your Docker installation, including:

  • Number of containers and images
  • Storage driver
  • Kernel version
  • Docker root directory

3. Run the Hello World Container

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

If Docker is installed properly, it will download a test image and run it. You should see a message explaining that your installation is working correctly.

Conclusion πŸŽ‰

Understanding Docker's architecture helped me tremendously when I first started with containers. Once you grasp how the client, daemon, and registry interact, everything else makes more sense.

After setting up Docker, I recommend running a few simple containers to get comfortable with the commands. The Docker system is quite elegant when you get to know it - the client-server model keeps things clean, and the building blocks (images, containers, networks, volumes) fit together logically.

Next time I'll cover working with containers - how to run them, manage their lifecycle, and interact with them in practical ways. That's where the real fun begins!


Next up: "Working with Docker Containers"

Top comments (0)