Table of Contents

Docker

Docker packages an application together with its dependencies into an image, then runs that image as an isolated process on a shared kernel. Unlike a virtual machine, there is no guest operating system — which is why a container starts in milliseconds and costs megabytes rather than gigabytes.

┌──────────────────────────────┐   ┌──────────────────────────────┐
│  Virtual Machines            │   │  Containers                  │
├──────────────────────────────┤   ├──────────────────────────────┤
│  App A    │  App B           │   │  App A    │  App B           │
│  Bins/Lib │  Bins/Lib        │   │  Bins/Lib │  Bins/Lib        │
│  Guest OS │  Guest OS        │   ├───────────┴──────────────────┤
├───────────┴──────────────────┤   │  Container runtime           │
│  Hypervisor                  │   ├──────────────────────────────┤
├──────────────────────────────┤   │  Host OS  (shared kernel)    │
│  Host OS                     │   ├──────────────────────────────┤
├──────────────────────────────┤   │  Hardware                    │
│  Hardware                    │   └──────────────────────────────┘
└──────────────────────────────┘

The shared kernel is also the main caveat: containers isolate processes, not kernels. A Linux container needs a Linux kernel, which is why Docker Desktop runs a VM on Windows and macOS, and why Windows containers are a separate thing entirely.

Core Concepts

Term What it is
Image A read-only, layered filesystem plus metadata. Built from a Dockerfile.
Container A running instance of an image, with a thin writable layer on top.
Volume Storage managed by Docker that outlives the container.
Network A virtual network containers attach to in order to reach each other.
Registry Where images are stored and distributed — Docker Hub, GHCR, Harbor.
Dockerfile The recipe an image is built from.
Compose A file format and CLI for running a multi-container application.

Getting Started

New to Docker, in order:

  1. Install Docker — Linux, Windows, or macOS
  2. Quickstart — run your first containers and build an image
  3. Working with Containers — lifecycle, inspection, and operations
  4. Docker Compose — define a multi-service application

In This Section

Fundamentals

Page Covers
Installing Docker Engine on Linux, Desktop on Windows and macOS, post-install setup
Quickstart First containers, images, ports, volumes
Working with Containers Lifecycle, inspection, security options, resource limits
Building Images Dockerfiles, layer caching, BuildKit, multi-arch, build secrets
Docker Compose Multi-container applications, environments, production patterns

Infrastructure

Page Covers
Networking Drivers, DNS, EXPOSE vs -p, firewall interaction, IPv6
Storage Volumes, bind-mount permissions, storage drivers, disk usage
Registries Authentication, tagging, private registries, mirrors, signing
GPU and Device Access NVIDIA GPUs, integrated graphics, USB and serial devices
Daemon Configuration daemon.json, systemd, remote engines, contexts
Monitoring and Logging Log drivers, docker stats, events, health checks, metrics

Advanced

Page Covers
Rootless and User Namespaces Running Docker without daemon root
Docker Swarm Clustering, services, stacks, rolling updates
Windows Containers Windows workloads, process vs Hyper-V isolation
Command Formatting Customizing CLI output with Go templates

Common Tasks

I want to… Start here
Make my container's data survive a restart Storage — Named Volumes
Fix "permission denied" on a mounted directory Storage — Permissions
Let two containers talk to each other by name Networking — Bridge Networks
Understand why a published port bypasses my firewall Networking — Firewall Interaction
Make builds faster Images — Layer Caching
Use a private registry Registries — Authentication
Stop Docker filling my disk Storage — Disk Usage and Pruning
Find out why a container exited Monitoring — Debugging a Container
Give a container access to a GPU or USB device GPU and Device Access
Reload code without rebuilding on every save Compose — Development Workflow
Run Docker without giving out root Rootless Docker

Quick Reference

Essential Docker Commands

# Container management
docker run <image>                   # Run a container
docker ps                            # List running containers
docker ps -a                         # List all containers
docker stop <container>              # Stop a container
docker start <container>             # Start a stopped container
docker restart <container>           # Restart a container
docker rm <container>                # Remove a container
docker exec -it <container> bash     # Execute a command in a container

# Image management
docker images                        # List images
docker pull <image>                  # Pull an image from a registry
docker build -t <name> .             # Build an image from a Dockerfile
docker rmi <image>                   # Remove an image
docker tag <image> <new-name>        # Tag an image

# System management
docker info                          # Display system information
docker version                       # Show Docker version
docker system df                     # Show disk usage
docker system prune                  # Remove unused data
docker logs <container>              # View container logs

Common Docker Run Options

# Background execution
docker run -d <image>

# Port mapping — bind to localhost unless it must be public
docker run -p 127.0.0.1:8080:80 <image>

# Named volume (preferred for application data)
docker run -v myvolume:/data <image>

# Bind mount
docker run -v /host/path:/container/path <image>

# Environment variables
docker run -e VAR_NAME=value <image>

# Interactive terminal
docker run -it <image> /bin/bash

# Remove container on exit
docker run --rm <image>

# Set container name
docker run --name my-container <image>

# Limit resources
docker run --memory=512m --cpus=1 <image>

Docker Compose Quick Commands

# Start services
docker compose up

# Start in background
docker compose up -d

# Stop services
docker compose down

# View logs
docker compose logs -f

# Rebuild images
docker compose up --build

# Scale a service
docker compose up -d --scale web=3
Note

Compose v2 is invoked as docker compose, not docker-compose. The hyphenated v1 binary is end-of-life and is not installed by current packages.