Docker Roadmap

From your first docker run to shipping containers to production: images, containers, Dockerfiles, volumes and networks, then Docker Compose, multi-stage builds, BuildKit and registries, then image security, secrets, the software supply chain and CI/CD, and finally what a container really is (namespaces and cgroups), resource limits, logging and running containers on real servers. 36 topics in four stages, each with what to learn, free resources, a practice task and, for most, an example you can paste into a terminal. Tick things off as you go; your progress is saved in this browser. Use the filter to follow the developer path, the DevOps & production path or the security & supply chain path.

Written for Docker Engine 29 (29.9.3, November 2026) and Docker Compose v5 (5.7.0); everything here also works with Compose 2.x. Every command and file on this page was run on Docker Engine 29 in November 2026 (the GitHub Actions workflow was checked against the actions' current inputs), and every link was checked.

The roadmap in detail

Everything from the map above, on one page. Dashed topics are optional. The hours are rough estimates for reading plus hands-on practice. Everything here runs for free on your own computer: Docker Engine on Linux, or Docker Desktop (free for personal use, education and small businesses) on Windows and macOS.

Stage 1 · Beginner Container fundamentals

Learn what a container is, run other people's images, then write your own Dockerfile and give containers storage and a network. By the end of this stage you can package a small app and run it anywhere Docker runs.

What containers are and why Docker

A container is an ordinary process on a Linux machine that has been given its own view of the system: its own file system, process list, network and hostname, plus limits on how much CPU and memory it may use. It feels like a tiny separate computer, but it shares the host's kernel, so it starts in milliseconds and costs almost nothing when idle.

The container's file system comes from an image: a read-only bundle of your app, its runtime and its libraries. Because the image carries everything the app needs, "it works on my machine" becomes "it works on every machine that runs containers": your laptop, CI and production. Docker made this easy in 2013 with a simple CLI, the Dockerfile and Docker Hub. Today the image and runtime formats are open standards (OCI), so images built with Docker also run on Podman, containerd and Kubernetes.

Containers are not virtual machines. A VM emulates hardware and boots its own kernel, which gives stronger isolation but costs gigabytes and seconds. Containers trade a little isolation for speed and density, which is why they are the usual unit of deployment for web services.

What to learn

  • Container vs virtual machine: shared kernel, start time, size, isolation
  • Image vs container: the template and the running instance
  • What problems containers solve: dependency clashes, "works on my machine", repeatable deploys
  • The pieces: Docker CLI, Docker Engine (dockerd), containerd, runc, registries
  • OCI: why an image built with Docker runs on Podman and Kubernetes too

Free resources

Practice

Write a short note for a teammate: what is the difference between a VM and a container, what does each share with the host, and which would you pick to run 30 small web services on one server? Then list three apps on your machine that would be easier to run in a container.

Prerequisites: Linux terminal and networking basics

Almost every image is a small Linux system, and you will spend a lot of time inside one with a shell. Know how to move around a terminal, read and set file permissions, see running processes and understand ports and IP addresses. Skip this topic if that is already familiar.

What to learn

  • Terminal basics: paths, ls, cd, cat, pipes and environment variables
  • Users, groups and file permissions (why "root inside the container" matters)
  • Processes and signals: PID, kill, SIGTERM vs SIGKILL
  • IP addresses, ports, localhost vs 0.0.0.0, DNS
  • Package managers: apt on Debian/Ubuntu, apk on Alpine

Free resources

Practice

Start a simple web server on your machine (for example python3 -m http.server 8080), find its PID and the port it listens on, stop it with SIGTERM, then start it bound only to 127.0.0.1 and check from another device that it is no longer reachable.

Install Docker and run your first container

On Linux, install Docker Engine from Docker's own apt/dnf repository (distribution packages are often old). On Windows and macOS, Docker Desktop runs the engine in a small Linux VM for you and adds a GUI. Docker Desktop is free for personal use, education, open source and businesses with fewer than 250 employees and under US$10 million in revenue; larger companies need a paid plan, or can use free alternatives such as Docker Engine on Linux, Podman or Rancher Desktop.

On Linux, adding your user to the docker group lets you run Docker without sudo, but that group is effectively root on the machine: anyone in it can mount the host's disk into a container. Use it on your own laptop; prefer rootless mode on shared servers.

docker run --rm hello-world   # "Hello from Docker!" if all is well
docker version                # client and server (engine) versions
docker info                   # storage driver, containers, images…

What to learn

  • Install Docker Engine on Linux (or Docker Desktop on Windows/macOS) from the official instructions
  • The post-install steps on Linux and what the docker group really allows
  • Read docker version and docker info: client, server, storage driver
  • Docker Desktop licensing in one sentence, and the free alternatives
  • Where to try Docker in the browser if you can't install it (Play with Docker)

Free resources

Practice

Install Docker, run hello-world and read every line of its output: it describes the four steps that just happened (client → daemon → pull → create and run). Write those four steps down in your own words.

Images, layers, tags and registries

An image is a stack of read-only layers, each one the file changes made by one build step, plus a small config (default command, environment, user, exposed ports). Images that share a base share those layers on disk and in downloads. A running container adds one thin writable layer on top; delete the container and that layer is gone.

Images are named registry/repository:tag, for example docker.io/library/nginx:1.30-alpine (the registry defaults to Docker Hub and the library/ prefix marks official images). A tag is a movable label: nginx:1.30 today may point to a different image next month. A digest (@sha256:…) names exact content and never changes, so pin digests where you need repeatable builds.

docker pull nginx:1.30-alpine
docker image ls                        # images on this machine
docker image history nginx:1.30-alpine # one line per layer
docker image inspect --format '{{.Config.Cmd}}' nginx:1.30-alpine
docker image inspect --format '{{index .RepoDigests 0}}' \
  nginx:1.30-alpine                    # nginx@sha256:…

What to learn

  • Layers, the union (overlay) file system and the container's writable layer
  • Image names: registry, repository, tag and digest
  • Why latest is just a tag, not "the newest", and why to avoid it in production
  • Docker Hub: official images, verified publishers, pull rate limits for anonymous users
  • Clean up with docker image prune and docker system df

Free resources

Practice

Pull python:3.15-slim and python:3.15. Compare their sizes and layer counts with docker image history, find the layers they share, and note each one's digest. Then run docker system df before and after docker image prune.

Running and managing containers

docker run creates and starts a container from an image. The flags you'll use every day: -d to run in the background, --name to give it a name, -p host:container to publish a port, -e to set environment variables, -it for an interactive terminal and --rm to delete it when it stops. Then ps, logs, exec, stop and rm manage it.

docker run -d --name web -p 127.0.0.1:8080:80 nginx:1.30-alpine
curl -I localhost:8080      # HTTP/1.1 200 OK
docker ps                   # running containers
docker port web             # 80/tcp -> 127.0.0.1:8080
docker logs -f web          # follow its output (Ctrl+C to stop)
docker exec -it web sh      # a shell inside the running container
docker stop web && docker rm web

-p 8080:80 on its own publishes on every network interface of the host, and Docker's firewall rules make it reachable from outside even if your host firewall says otherwise. Bind to 127.0.0.1 when only your machine should reach it.

What to learn

  • docker run flags: -d, --name, -p, -e, -it, --rm
  • docker ps / ps -a, logs, exec, stop, start, rm
  • Publishing ports, and why 127.0.0.1:8080:80 is safer than 8080:80
  • Interactive containers: docker run -it --rm alpine:3.24 sh
  • Copy files in and out with docker cp

Free resources

Practice

Run nginx, PostgreSQL (postgres:18 with POSTGRES_PASSWORD set) and Redis (redis:8.10) side by side, each on its own localhost port. Connect to each, read each one's logs, open a shell in one, then stop and remove all three with one command.

Container lifecycle, exit codes and restart policies

A container lives exactly as long as its main process (PID 1). When that process exits, the container stops, and the process's exit code becomes the container's. docker stop sends SIGTERM, waits 10 seconds, then sends SIGKILL, so your app should catch SIGTERM and shut down cleanly. Exit code 137 means the process was killed with SIGKILL, often by the out-of-memory killer; 143 means it exited because of SIGTERM.

Restart policies tell Docker what to do when a container stops: no (default), on-failure[:N], unless-stopped or always. They also bring containers back after the Docker daemon or the machine restarts.

docker run --rm alpine:3.24 sh -c 'exit 3'; echo $?    # 3

docker run -d --name flaky --restart on-failure:3 \
  alpine:3.24 sh -c 'exit 1'
docker inspect -f '{{.RestartCount}} {{.State.Status}}' flaky
# 3 exited   (gave up after three restarts)
docker rm -f flaky

What to learn

  • States: created, running, paused, restarting, exited
  • PID 1 and signals: why shell-form commands can swallow SIGTERM
  • Exit codes: 0, 1, 137 (SIGKILL / out of memory), 143 (SIGTERM)
  • Restart policies, and the difference between always and unless-stopped
  • Graceful shutdown: --stop-timeout, STOPSIGNAL and --init

Free resources

Practice

Write a tiny script that prints "shutting down" when it receives SIGTERM. Run it in a container and time docker stop: it should return in under a second. Then start it from a small shell script that runs it without exec and time it again; explain why it now takes 10 seconds and how exec or --init fixes it.

Writing your first Dockerfile

A Dockerfile is the recipe for an image: start FROM a base image, set a WORKDIR, COPY your files in, RUN commands to install dependencies, and set the default command with CMD. docker build runs the steps in order and each one produces a layer. The example below packages a small Python (Flask) web app.

FROM python:3.15-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV APP_ENV=production
EXPOSE 8000
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]
docker build -t myapp:1.0 .
docker run -d --name myapp -p 127.0.0.1:8000:8000 myapp:1.0
curl localhost:8000    # {"env":"production","message":"hello"}

Inside a container, your app must listen on 0.0.0.0, not 127.0.0.1: the container's localhost is its own, so a server bound there can't be reached through a published port. EXPOSE is documentation only; -p is what publishes a port.

What to learn

  • The core instructions: FROM, WORKDIR, COPY, RUN, ENV, EXPOSE, CMD
  • COPY vs ADD (prefer COPY; ADD also fetches URLs and unpacks archives)
  • The build context: what . in docker build . sends to the builder
  • Tagging images with a version, not only latest
  • Listening on 0.0.0.0 inside the container

Free resources

Practice

Containerise a small app you wrote (any language). Build it, run it with a published port, change one line of code, rebuild and run again. Paste your Dockerfile into the Docker validator and fix what it reports.

Layer caching and .dockerignore

When you rebuild, Docker reuses each layer whose instruction and inputs haven't changed, and rebuilds everything after the first one that has. That is why the Dockerfile above copies requirements.txt and installs dependencies before copying the rest of the code: editing your code then only re-runs the last COPY, not the slow install. Put things that change rarely near the top and things that change often near the bottom.

A .dockerignore file keeps files out of the build context: faster builds, fewer cache misses, and no .git folder, local .env or secrets accidentally copied into the image.

# .dockerignore
.git
__pycache__/
*.pyc
.env
.venv/
Dockerfile
compose*.yaml

What to learn

  • How the cache decides: the instruction text, plus file checksums for COPY and ADD
  • Order instructions from least to most frequently changing
  • Copy dependency manifests first (requirements.txt, package.json, go.mod, pom.xml)
  • Combine apt-get update and install in one RUN and clean up in the same layer
  • Write a .dockerignore; rebuild from scratch with --no-cache when needed

Free resources

Practice

Time a rebuild after a one-line code change with the dependency install placed after COPY . ., then move it before and time again. Add a 100 MB dummy file to the folder and see how the build context size changes with and without .dockerignore.

CMD, ENTRYPOINT, exec form and shell form

ENTRYPOINT is the program a container always runs; CMD gives its default arguments (or the whole command when there is no ENTRYPOINT). Arguments after the image name in docker run replace CMD; --entrypoint replaces ENTRYPOINT.

FROM alpine:3.24
ENTRYPOINT ["echo", "hello"]
CMD ["world"]

# docker run --rm greet                    -> hello world
# docker run --rm greet Docker             -> hello Docker
# docker run --rm --entrypoint date greet  -> prints the date

Write both in exec form (a JSON array). The shell form (CMD gunicorn app:app) runs your app through /bin/sh -c. On Debian-based images the shell then stays PID 1 and your app is its child, so the app never receives the SIGTERM from docker stop and gets killed 10 seconds later. (Some shells hand over to a single command, but don't rely on it.)

What to learn

  • How ENTRYPOINT and CMD combine, and how docker run overrides each
  • Exec form vs shell form, and why exec form gets signals
  • Entrypoint scripts that end with exec "$@"
  • When to use only CMD (most apps) vs ENTRYPOINT (tool-like images)

Free resources

Practice

Build an image for a command-line tool (for example a script that converts CSV to JSON) with ENTRYPOINT set to the tool and CMD set to --help. Show that docker run image prints help and docker run image input.csv runs it.

Volumes and bind mounts: keeping data

Anything a container writes to its own file system disappears when the container is removed. To keep data, mount storage into it. A named volume is managed by Docker and is the right choice for databases. A bind mount maps a folder from your machine, which is ideal for live-editing source code in development. A tmpfs mount lives in memory only.

docker volume create appdata
docker run --rm -v appdata:/data alpine:3.24 \
  sh -c 'echo hello > /data/note.txt'
docker run --rm -v appdata:/data alpine:3.24 cat /data/note.txt
# hello   (the data outlived the first container)

# back up a volume to a .tgz in the current folder
docker run --rm -v appdata:/data:ro -v "$PWD":/backup \
  alpine:3.24 tar czf /backup/appdata.tgz -C /data .

What to learn

  • Named volumes vs bind mounts vs tmpfs, and when to use each
  • -v vs --mount syntax, read-only mounts (:ro)
  • Where the official database images keep their data (for example /var/lib/postgresql for PostgreSQL 18)
  • File ownership problems with bind mounts and non-root users
  • Backing up and restoring a volume; docker volume ls, inspect, rm, prune

Free resources

Practice

Run PostgreSQL with a named volume, create a table and a row, remove the container, start a new one on the same volume and check the row is still there. Back the volume up to a .tgz, delete the volume, restore it from the backup and check again.

Container networking

Each container gets its own network stack. By default containers join the bridge network, where they can reach each other by IP but not by name. Create your own bridge network and Docker's built-in DNS lets containers find each other by container name, which is how an app talks to its database. Other drivers: host (share the host's network, Linux only), none, and overlay for multi-host Swarm.

docker network create appnet
docker run -d --rm --name cache --network appnet redis:8.10
docker run --rm --network appnet redis:8.10 \
  redis-cli -h cache PING              # PONG

docker run --rm alpine:3.24 ping -c1 cache
# ping: bad address 'cache'   (default bridge: no DNS by name)
docker stop cache && docker network rm appnet

What to learn

  • The default bridge vs user-defined bridge networks (name resolution, isolation)
  • Container-to-container traffic doesn't need published ports
  • host, none and overlay drivers, and when they make sense
  • Reaching a service on the host from a container (host.docker.internal, --add-host)
  • docker network ls, inspect, connect, disconnect

Free resources

Practice

Put an app and a database on one user-defined network with only the app's port published. Prove the database can't be reached from your host, the app can reach it by name, and a container on a second network can't reach it at all.

Am I ready? Stage 1 quiz

What is the main difference between a container and a virtual machine?

  1. Containers can only run Linux distributions made by Docker
  2. Containers always run as root, VMs never do
  3. A container shares the host's kernel; a VM boots its own kernel on emulated hardware
  4. VMs start faster because they skip the kernel

Containers are isolated processes on the host kernel, which is why they are small and start in milliseconds.

You edit one line of app code and rebuild, but pip install runs again every time. What's the likely cause?

  1. COPY . . comes before the install step, so any code change invalidates the cache for the install
  2. Docker never caches RUN instructions
  3. The base image is too small
  4. You forgot EXPOSE

Copy only the dependency file, install, then copy the rest. Code changes then only re-run the last COPY.

Your app runs in a container with -p 8000:8000 but curl localhost:8000 on the host gets no response. The app logs say it listens on 127.0.0.1:8000. What's wrong?

  1. EXPOSE is missing from the Dockerfile
  2. Port 8000 is reserved by Docker
  3. You need --network host on every platform
  4. The app listens on the container's own localhost; it must listen on 0.0.0.0

The container has its own loopback interface. Published traffic arrives on the container's network interface, so bind to 0.0.0.0.

Two containers on the default bridge network can't reach each other by name. What's the simplest fix?

  1. Publish both ports on the host
  2. Create a user-defined network and attach both containers to it
  3. Use the containers' IDs as hostnames
  4. Edit /etc/hosts in both images

User-defined bridge networks have built-in DNS that resolves container names; the default bridge doesn't.

A PostgreSQL container was removed and recreated, and all the data is gone. What should you have done?

  1. Used docker stop instead of docker rm every time
  2. Committed the container to a new image
  3. Mounted a named volume at the database's data directory
  4. Set a restart policy

The container's writable layer is deleted with the container. A named volume lives on independently and is reattached to the new container.

Stage 2 · Intermediate Building real apps

Real apps are several containers working together, built fast and small, configured per environment and stored in a registry. This stage covers Docker Compose, multi-stage builds, BuildKit features, images for more than one CPU type, health checks and debugging.

Docker Compose: multi-container apps

Docker Compose describes a whole app (services, networks and volumes) in one compose.yaml file and starts it with docker compose up. Compose creates a network for the project, so services reach each other by service name (db below). It's the standard way to run an app and its database, cache and queue on a laptop and in CI.

services:
  web:
    build: .
    ports:
      - "127.0.0.1:8000:8000"
    environment:
      APP_ENV: ${APP_ENV:-dev}
      DATABASE_URL: postgresql://app:${DB_PASSWORD}@db:5432/app
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    image: postgres:18
    environment:
      POSTGRES_USER: app
      POSTGRES_DB: app
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - db-data:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app -d app"]
      interval: 5s
      timeout: 3s
      retries: 10

volumes:
  db-data:
echo "DB_PASSWORD=change-me" > .env   # read by compose for ${...}
docker compose up -d --build --wait  # wait until healthy
docker compose ps                    # db and web: Up (healthy)
docker compose logs -f web
docker compose exec db psql -U app -d app
docker compose down        # add -v to delete the volume too

Compose v2 and later is the docker compose plugin (with a space), written in Go. The old Python docker-compose (with a hyphen) and the top-level version: key are both obsolete; drop them from old files.

What to learn

  • The file: services, image vs build, ports, environment, volumes, networks
  • up, down, ps, logs, exec, run, build, pull
  • Service names as hostnames on the project network
  • Startup order: depends_on with condition: service_healthy
  • Project names and why two copies of a project don't clash; down -v deletes data

Free resources

Practice

Write a compose.yaml for an app with a web service, PostgreSQL and Redis. The web service must wait until the database is healthy, only the web port may be published (on 127.0.0.1), and data must survive docker compose down but not down -v. Check the file with the Compose validator.

Compose for development: watch, profiles and overrides

Compose has features made for the inner loop of development. Watch (docker compose watch or up --watch) syncs your code into the running container as you save and restarts or rebuilds when needed. Profiles mark optional services (a database UI, a mail catcher) that only start when you ask. A compose.override.yaml next to compose.yaml is merged in automatically, so development-only settings stay out of the main file.

# compose.override.yaml (merged into compose.yaml automatically)
services:
  web:
    command: gunicorn --reload -b 0.0.0.0:8000 app:app
    environment:
      APP_ENV: dev
    develop:
      watch:
        - action: sync
          path: .
          target: /app
          ignore:
            - .venv/
        - action: rebuild
          path: requirements.txt

  adminer:
    image: adminer:5
    profiles: [debug]
    ports:
      - "127.0.0.1:8081:8080"

Here watch copies each saved file into the container and gunicorn's --reload picks it up; a change to requirements.txt rebuilds the image. For apps without a reloader, sync+restart restarts the container after syncing.

docker compose up --watch              # sync code as you save
docker compose --profile debug up -d   # also start adminer
docker compose config                  # the merged, final file

What to learn

  • Watch actions: sync, sync+restart, rebuild
  • Bind-mounting source code vs watch: trade-offs on macOS and Windows
  • Profiles for optional services
  • Override files, -f to combine files, and include
  • docker compose config to see what Compose will actually run

Free resources

Practice

Add watch to your Compose project so that a code change shows up in the browser within two seconds without a manual rebuild, while changing the dependency file triggers a rebuild. Add a debug profile with a database UI.

Configuration and environment variables

Build one image and run it everywhere; change behaviour per environment with configuration, not with different images. Environment variables are the usual way in: -e and --env-file for docker run, environment and env_file in Compose. Compose also reads a .env file to fill in ${VARIABLES} in the YAML itself, which is a different job from passing variables into the container.

printf 'APP_ENV=staging\nLOG_LEVEL=debug\n' > app.env
docker run --rm --env-file app.env -e LOG_LEVEL=info \
  alpine:3.24 sh -c 'echo $APP_ENV $LOG_LEVEL'
# staging info   (-e wins over the env file)

What to learn

  • Build-time ARG vs runtime ENV, and why neither is for secrets
  • -e, --env-file, and which value wins
  • Compose interpolation: ${VAR}, ${VAR:-default}, ${VAR:?error} and the .env file
  • Config files mounted read-only, and Compose configs
  • Twelve-factor config: one image, many environments

Free resources

Practice

Run the same image as "dev" and "staging" with different env files, and make the app refuse to start when a required variable is missing. In Compose, make DB_PASSWORD required with ${DB_PASSWORD:?set DB_PASSWORD} and check the error.

Multi-stage builds

A multi-stage build uses one stage with compilers and build tools to produce your app, then copies only the result into a clean final stage. The final image has no compilers, no dev dependencies and no source you didn't need, so it is smaller and has fewer vulnerabilities. For compiled languages (Go, Rust, Java) the gain is huge; for Python and Node.js it keeps build tools out.

# syntax=docker/dockerfile:1

# ---- build stage: install dependencies into a virtualenv ----
FROM python:3.15-slim AS build
RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"
WORKDIR /build
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r requirements.txt

# ---- runtime stage: copy only what the app needs ----
FROM python:3.15-slim
RUN useradd --create-home --uid 10001 app
COPY --from=build /venv /venv
ENV PATH="/venv/bin:$PATH" PYTHONUNBUFFERED=1
WORKDIR /app
COPY --chown=app:app app.py .
USER 10001
EXPOSE 8000
HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD ["python", "-c", \
  "import urllib.request as u; u.urlopen('http://localhost:8000/')"]
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]

This Dockerfile pulls together several later topics: a BuildKit cache mount, a non-root user and a health check. docker build --target build stops at a named stage, which is handy for running tests in CI.

What to learn

  • Naming stages with AS and copying with COPY --from=
  • Building one stage with --target (test, dev, production stages)
  • Copying build output from an external image (COPY --from=image)
  • Patterns for compiled languages: build a binary, ship it on a tiny base
  • Stages that don't feed the final image are skipped by BuildKit

Free resources

Practice

Write a multi-stage Dockerfile for a compiled program (a Go or Rust "hello web" is ideal) and compare the final image size with a single-stage build. Add a test stage and run only that stage with --target test.

Choosing base images and keeping images small

The base image decides most of your image's size, its security patches and what tools you get. Common choices: Debian slim images (python:3.15-slim, node:24-slim), a good default; Alpine, tiny but built on musl libc, which some compiled packages and tools don't like; distroless images, which contain only your runtime and no shell or package manager; scratch, an empty image for static binaries; and hardened images such as Docker Hardened Images (free since December 2025), which are minimal and patched quickly.

Smaller images pull faster and have less to attack, but don't chase megabytes at the cost of a base image nobody on your team can debug. Pin a specific version tag (3.15-slim, not latest) and rebuild regularly so security fixes land.

What to learn

  • Official images, slim variants, Alpine (musl) and their trade-offs
  • Distroless and scratch: no shell, so how do you debug?
  • Hardened and minimal images: Docker Hardened Images, Chainguard, distroless
  • Removing package caches in the same RUN, and not installing "just in case" tools
  • Measuring: docker image ls, docker image history

Free resources

Practice

Build the same app on four bases (full Debian, slim, Alpine, distroless or a hardened image) and make a table of size, build time, whether it has a shell, and how many known vulnerabilities a scanner reports for each.

BuildKit and Buildx: faster, smarter builds

BuildKit is the build engine behind docker build, and Buildx is the CLI plugin that drives it. It builds independent stages in parallel and adds Dockerfile features older guides don't know: cache mounts that keep package-manager caches between builds, secret mounts for tokens needed during the build, SSH forwarding for private Git repositories, and exporting the build cache to a registry or to CI.

# syntax=docker/dockerfile:1
FROM node:24-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
    npm ci --omit=dev
COPY . .
CMD ["node", "server.js"]

The # syntax=docker/dockerfile:1 line makes BuildKit use the latest stable Dockerfile frontend, so new features work even on an older engine.

What to learn

  • What BuildKit adds: parallel stages, skipping unused stages, better caching
  • Cache mounts (--mount=type=cache) for pip, npm, Maven, Go and apt
  • docker buildx: builders, drivers (docker, docker-container) and --progress=plain
  • External cache: --cache-to / --cache-from (registry, GitHub Actions)
  • Build arguments, labels and docker buildx bake for several images

Free resources

Practice

Add a cache mount to your dependency install, change one dependency and compare the rebuild time with and without the mount. Then create a docker-container builder and export the cache to a local directory with --cache-to type=local.

Multi-platform images (amd64 and arm64)

Apple Silicon laptops, AWS Graviton and Raspberry Pis run arm64; most servers run amd64. An image built on one may not run on the other ("exec format error"). A multi-platform image is one name that points to an index of per-platform images, and Docker pulls the right one automatically. Buildx builds them with QEMU emulation, cross-compilation or native builders for each platform.

docker buildx create --name multi --driver docker-container
docker buildx build --builder multi \
  --platform linux/amd64,linux/arm64 \
  -t registry.example.com/myapp:1.0 --push .
docker buildx imagetools inspect registry.example.com/myapp:1.0
# Platform: linux/amd64 ... Platform: linux/arm64

What to learn

  • Platforms (linux/amd64, linux/arm64) and image indexes (manifest lists)
  • Why the classic image store can't hold multi-platform images and the containerd image store can
  • QEMU emulation vs cross-compilation (BUILDPLATFORM / TARGETPLATFORM) vs native builders
  • Running a different platform locally with --platform
  • Inspecting an index with docker buildx imagetools inspect

Free resources

Practice

Run a local registry (registry:3), build your app for amd64 and arm64, push it, inspect the index, and run the arm64 variant on an amd64 machine with --platform linux/arm64 (it works through emulation, slowly).

Health checks

"Running" only means the process hasn't exited. A health check runs a command inside the container at an interval and marks it healthy or unhealthy. Compose uses it for depends_on: condition: service_healthy, Swarm replaces unhealthy tasks, and your monitoring can alert on it. (Kubernetes ignores Docker health checks and uses its own probes.)

docker run -d --name web myapp:1.0     # image with a HEALTHCHECK
docker inspect --format '{{.State.Health.Status}}' web
# starting, then healthy
docker ps                              # STATUS: Up 20 seconds (healthy)

What to learn

  • HEALTHCHECK in a Dockerfile and healthcheck: in Compose
  • interval, timeout, retries, start_period
  • What makes a good check: cheap, local, and tests that the app can serve
  • Health checks in images without curl (use the app's own runtime or a tiny binary)
  • Docker health checks vs Kubernetes liveness and readiness probes

Free resources

Practice

Add a health check to your app, then make the app hang (for example an endpoint that sleeps forever and blocks the worker). Watch the status turn unhealthy and see how Compose's depends_on reacts on the next up.

Debugging containers

Most container problems are one of: the process exited (read the logs and the exit code), it can't reach something (network or DNS), it can't read or write a file (permissions or a missing mount), or it's out of memory. A small set of commands answers almost all of them.

docker ps -a                       # did it exit? with what code?
docker logs --tail 50 web          # last 50 lines of output
docker inspect web                 # config, mounts, network, state
docker exec -it web sh             # look around inside
docker stats --no-stream           # CPU and memory right now
docker events --since 10m          # what Docker did recently
docker run --rm -it --network container:web \
  nicolaka/netshoot:v0.16          # network tools, same network

What to learn

  • Read logs, exit codes and docker inspect output
  • Get a shell in a running container, or start one with --entrypoint sh when it keeps crashing
  • Debug images without a shell: attach a debug container to the same network or PID namespace
  • docker stats, docker top, docker events and docker diff
  • Build problems: --progress=plain and --no-cache

Free resources

Practice

Ask a friend (or yourself, a week later) to break your Compose app in three ways: a wrong database host, a read-only volume the app writes to, and a memory limit that's too low. Find each cause using only the commands above and write down which one gave it away.

Registries: pushing, pulling and tagging

A registry stores and serves images. Docker Hub is the default; GitHub Container Registry (ghcr.io), Amazon ECR, Google Artifact Registry and Azure Container Registry are common for private images, and you can run your own with the open source registry image (CNCF Distribution). Tag an image with the registry's address, log in, and push.

docker run -d --name registry -p 127.0.0.1:5000:5000 registry:3
docker tag myapp:1.0 localhost:5000/myapp:1.0
docker push localhost:5000/myapp:1.0
curl localhost:5000/v2/_catalog   # {"repositories":["myapp"]}
docker image inspect --format '{{index .RepoDigests 0}}' \
  localhost:5000/myapp:1.0        # localhost:5000/myapp@sha256:…

What to learn

  • docker login, tag, push, pull; access tokens instead of passwords
  • A tagging strategy: semantic versions plus the Git commit SHA; never overwrite a release tag
  • Deploy by digest so what you tested is exactly what runs
  • Private registries: GHCR, ECR, Artifact Registry, ACR, Harbor
  • Retention and clean-up policies so the registry doesn't grow forever

Free resources

Practice

Push your app to a local registry and to a free registry account (Docker Hub or GHCR) with two tags: the version and the short Git SHA. Pull it on another machine (or after deleting it locally) by digest and run it.

Am I ready? Stage 2 quiz

In Compose, the web service starts before PostgreSQL accepts connections and crashes. What's the right fix?

  1. Add sleep 30 to the web service's command
  2. Give the database a healthcheck and use depends_on with condition: service_healthy
  3. List db before web in the file
  4. Use restart: always on the database

Plain depends_on only waits for the container to start, not for the database to be ready. A health condition waits for readiness. (Apps should still retry connections.)

Why does a multi-stage build usually give a smaller, safer image?

  1. It compresses layers better
  2. It runs the build on a different machine
  3. It skips the build cache
  4. Compilers, dev dependencies and source stay in the build stage; only the output is copied into the final stage

The final stage starts clean and receives only what you COPY --from the build stage.

An image built on an Apple Silicon Mac fails on an amd64 server with "exec format error". What do you do?

  1. Build a multi-platform image with docker buildx build --platform linux/amd64,linux/arm64
  2. Switch the base image to Alpine
  3. Run the container with --privileged
  4. Rebuild with --no-cache

The image only contains arm64 binaries. Build for both platforms and push one index; each machine pulls its own variant.

Compose reads .env in the project folder. What is it used for?

  1. It's copied into every image at build time
  2. It's only used by Docker Desktop
  3. Filling in ${VARIABLES} in compose.yaml; it isn't passed into containers unless you reference it
  4. Storing secrets encrypted

.env feeds interpolation in the Compose file. Use environment or env_file to pass values into a container.

You deploy myapp:1.4, but the image on one server differs from the one you tested. How do you prevent this?

  1. Always use the latest tag
  2. Deploy by digest (myapp@sha256:…) and never overwrite release tags
  3. Use a bigger base image
  4. Run docker system prune before every deploy

Tags can be moved; a digest identifies exact content.

Stage 3 · Intermediate to advanced Security and CI/CD

An image is software you ship, with everything inside it. This stage makes your images safe to run (least privilege, no secrets, scanned and signed) and builds them automatically on every change.

Least privilege: non-root users, read-only file systems and capabilities

By default the process in a container runs as root. Namespaces keep it inside the container, but if anything breaks out (a kernel bug, a bad mount, a misconfiguration) it is root on the host. Create a user in the Dockerfile and switch to it with USER; then drop what the app doesn't need at run time.

# in the Dockerfile
RUN useradd --create-home --uid 10001 app
USER 10001
docker run --rm --read-only --cap-drop ALL \
  --security-opt no-new-privileges --user 1000:1000 \
  alpine:3.24 sh -c 'id; touch /x'
# uid=1000 gid=1000 groups=1000
# touch: /x: Read-only file system

What to learn

  • USER with a fixed numeric UID, and files the app needs owned by it (COPY --chown)
  • Ports below 1024 and non-root: listen on 8000 or 8080 instead
  • --read-only with a tmpfs for the few paths that must be writable
  • Linux capabilities: --cap-drop ALL, adding back only what's needed
  • no-new-privileges, and why --privileged almost never belongs in production

Free resources

Practice

Make your app run with --read-only --cap-drop ALL --security-opt no-new-privileges as a non-root user. Each time it fails, find out which path or capability it needed and allow only that (a tmpfs, a volume or one capability).

Scanning images for vulnerabilities and lint

Base images and dependencies get new CVEs every week. A scanner reads the packages in an image, compares them with vulnerability databases and tells you what to upgrade. Popular choices are Docker Scout (built into Docker Desktop, needs a free Docker account), Trivy and Grype (both open source). A linter such as Hadolint catches Dockerfile mistakes before you build.

docker run --rm aquasec/trivy:0.76.1 image \
  --severity HIGH,CRITICAL python:3.15-slim
docker run --rm -i hadolint/hadolint:v2.15.1 < Dockerfile

Pin scanner versions in CI like any other dependency: in March 2026 attackers hijacked release tags of Trivy's GitHub Actions, and pipelines that used a moving tag ran their code.

What to learn

  • What a CVE and a severity score are, and why "0 vulnerabilities" isn't the goal
  • Scan locally and in CI; fail the build only on fixable high and critical issues
  • Fix by updating the base image and dependencies, then rebuilding
  • Lint Dockerfiles with Hadolint or the Docker build checks (docker build --check)
  • Rebuild images regularly, not only when your code changes

Free resources

Practice

Scan your app image, list the high and critical findings and which ones have a fixed version. Bring the count down by changing only the base image tag and rebuilding, then add a scan step to CI that fails on fixable critical issues.

Secrets in builds and at run time

Never put secrets in a Dockerfile ENV or ARG, and never COPY them in: anyone who can pull the image can read every layer and its build history, even if a later step deletes the file. For tokens needed during the build (a private package registry), use a BuildKit secret mount, which is available to one RUN step and never written to a layer. At run time, pass secrets from your platform's secret store, or as files with Compose secrets.

# syntax=docker/dockerfile:1
FROM alpine:3.24
RUN --mount=type=secret,id=api_token \
    test -s /run/secrets/api_token && echo "token is available"

# docker build --secret id=api_token,src=token.txt -t demo .
# compose.yaml: the secret appears as /run/secrets/db_password
services:
  app:
    image: myapp:1.0
    secrets:
      - db_password

secrets:
  db_password:
    file: ./db_password.txt

What to learn

  • Why ENV, ARG and deleted files leak (layers and docker history)
  • Build secrets: --mount=type=secret and --secret; SSH forwarding with --mount=type=ssh
  • Runtime secrets: files under /run/secrets, environment variables, and their trade-offs
  • Secret stores: cloud secret managers, Vault, Kubernetes Secrets
  • Keep .env files out of the image and out of Git

Free resources

Practice

Build an image the wrong way with ARG TOKEN and find the token with docker history. Rebuild it with a secret mount and show that neither the history nor any layer contains it. Then move your database password in Compose from environment to secrets.

Supply chain: SBOMs, provenance and signing

Before you run an image you should be able to answer: what's inside it, where and how was it built, and has it been changed since? An SBOM (software bill of materials) lists every package in the image. Provenance records how it was built: the source repository, commit and build steps. A signature (for example with Sigstore's cosign) proves who published it. BuildKit can attach SBOM and provenance attestations to the image when it pushes.

docker buildx build --builder multi --sbom=true \
  --provenance=mode=max -t registry.example.com/myapp:1.0 --push .
docker buildx imagetools inspect registry.example.com/myapp:1.0 \
  --format '{{json .SBOM}}'          # the SPDX package list

What to learn

  • SBOM formats (SPDX, CycloneDX) and what they are used for
  • Build provenance and the SLSA levels
  • Signing and verifying images with cosign (keyless signing in CI)
  • Pinning base images by digest and updating them with a bot (Dependabot, Renovate)
  • Admission policies that only run signed images (more in the Kubernetes roadmap)

Free resources

Practice

Push your image with an SBOM and provenance to a registry, read both back with imagetools inspect, sign the image with cosign and verify the signature. Change one layer, push again, and check that the old signature no longer matches the new digest.

Runtime security: the Docker socket, rootless mode, seccomp and AppArmor

The Docker daemon runs as root, and anyone who can talk to it controls the machine. Mounting /var/run/docker.sock into a container hands that container root on the host, so only do it for tools you trust completely. Rootless mode runs the daemon and containers as an ordinary user. Docker also applies a default seccomp profile (blocks dangerous system calls) and, on Ubuntu and Debian, an AppArmor profile; don't turn them off.

docker info --format '{{.SecurityOptions}}'
# [name=apparmor name=seccomp,profile=builtin name=cgroupns]

What to learn

  • Why the docker group and the Docker socket are root-equivalent
  • Rootless Docker and user namespace remapping
  • The default seccomp and AppArmor profiles; what --privileged turns off
  • Protecting the daemon: no unauthenticated TCP socket, TLS if remote access is needed
  • Keeping the host and Docker Engine patched

Free resources

Practice

On a throwaway VM, show that a container with the Docker socket mounted can read /etc/shadow on the host. Then install rootless Docker for a normal user and run the same app; note what changes (ports below 1024, networking, where data lives).

Building images in CI/CD

Build, test, scan and push the image on every change, so the image that runs in production is the one CI produced, never one built on a laptop. Docker's official GitHub Actions set up Buildx, log in to the registry, generate tags from Git and build with a shared cache. The workflow below pushes to GitHub Container Registry on every push to main and on version tags.

name: image
on:
  push:
    branches: [main]
    tags: ["v*"]
permissions:
  contents: read
  packages: write
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: docker/setup-buildx-action@v4
      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - id: meta
        uses: docker/metadata-action@v6
        with:
          images: ghcr.io/${{ github.repository }}
      - uses: docker/build-push-action@v7
        with:
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max
          sbom: true
          provenance: mode=max

What to learn

  • Build → test → scan → push, and only deploy what CI pushed
  • Registry login with short-lived tokens (GITHUB_TOKEN, OIDC to a cloud registry)
  • Tags from Git: branch, version and commit SHA (metadata-action)
  • Build cache in CI: type=gha or a registry cache
  • Pin third-party actions to a full commit SHA in sensitive pipelines

Free resources

Practice

Add this workflow to a repository, push a commit and a v1.0.0 tag, and check the tags that appear in GHCR. Add a test step that runs your test stage with --target test and a scan step, and make a failing test block the push.

Testing with containers (Testcontainers and Compose in CI)

Tests against a real PostgreSQL, Redis or Kafka catch bugs that mocks hide. Testcontainers libraries (Java, Go, Python, Node.js, .NET and more) start throwaway containers from inside your test code and remove them afterwards. For end-to-end tests, start the whole Compose project in CI, wait until it's healthy, run the tests and tear it down.

What to learn

  • Testcontainers: start a database container per test suite and read its mapped port
  • Wait strategies: health checks, log messages, open ports
  • Compose in CI: up --wait, run tests, down -v
  • Speed: reuse containers between tests, and keep test images small

Free resources

Practice

Write one integration test that starts PostgreSQL with Testcontainers, runs your migrations and checks a query. Run it in CI and compare its run time with your unit tests.

Am I ready? Stage 3 quiz

A Dockerfile has ARG NPM_TOKEN and uses it in RUN npm ci. What's the problem?

  1. ARG values can't be used in RUN
  2. npm ignores tokens in containers
  3. The build will be slower
  4. The token can end up in the image's build history and metadata; use a secret mount instead

Build arguments are recorded with the image. A --mount=type=secret exists only during that RUN step and is never written to a layer.

Why is mounting /var/run/docker.sock into a container risky?

  1. Whoever controls that container can start privileged containers and mount the host's disk: it's root on the host
  2. It makes the container slower
  3. It only works with Docker Desktop
  4. It exposes the container's port to the internet

The Docker API can do anything root can do on the host.

A scanner reports 40 vulnerabilities in your image, 35 of them in the base image. What's the most effective first step?

  1. Ignore them; scanners are always wrong
  2. Turn on --privileged so the scanner can see more
  3. Move to a newer or more minimal base image tag and rebuild
  4. Delete the vulnerable files in a later RUN step

Most findings come from the base image. Deleting files in a later layer doesn't remove them from earlier layers.

Which set of run options gives a web app the least privilege it usually needs?

  1. --privileged --user root
  2. A non-root user, --read-only with a tmpfs for /tmp, --cap-drop ALL, no-new-privileges
  3. --network host and --pid host
  4. Default options are already least privilege

By default containers run as root with a writable file system and a default set of capabilities. Remove what the app doesn't need.

What does a provenance attestation tell you about an image?

  1. The list of CVEs in it
  2. Who downloaded it
  3. How much memory it needs
  4. How it was built: source repository, commit, build steps and builder

Provenance is the build record; the SBOM is the package list; a signature proves who published it.

Stage 4 · Advanced Production and beyond

Understand what Docker actually does in the kernel, run containers on real servers with limits, logs and monitoring, and know when it's time to move on to an orchestrator such as Kubernetes.

Under the hood: namespaces, cgroups, OCI and containerd

There is no "container" object in the Linux kernel. Docker assembles one from kernel features: namespaces give the process its own view of PIDs, network, mounts, hostname and users; cgroups limit and account for its CPU, memory and I/O; an overlay file system stacks image layers; and seccomp, AppArmor and capabilities restrict what it may do. The CLI talks to dockerd, which uses containerd to manage images and containers and runc to create each one according to the OCI runtime spec.

docker run --rm alpine:3.24 ps
# PID 1 is ps itself: its own PID namespace
docker run --rm --memory 64m alpine:3.24 \
  cat /sys/fs/cgroup/memory.max    # 67108864 (64 MiB, a cgroup)
docker run --rm --cpus 0.5 alpine:3.24 \
  cat /sys/fs/cgroup/cpu.max       # 50000 100000 (half a CPU)

What to learn

  • The namespaces: pid, net, mnt, uts, ipc, user, cgroup
  • cgroups v2: memory, CPU and PID limits, and where to see them
  • OverlayFS: lower layers, upper layer and copy-on-write
  • The stack: docker CLI → dockerd → containerd → runc, and the OCI image and runtime specs
  • Docker Desktop's Linux VM on macOS and Windows, and why bind mounts are slower there

Free resources

Practice

Start a container, find its process on the host with docker inspect -f '{{.State.Pid}}', and compare /proc/<pid>/ns with your shell's. Then use unshare to give a shell its own PID and UTS namespace without Docker at all.

Resource limits and the OOM killer

Without limits, one container can eat all the memory or CPU on the host and take the others down with it. Set a memory limit on every production container: when the process goes over it, the kernel's out-of-memory killer stops it and the container exits with code 137. CPU limits throttle rather than kill. Many runtimes (the JVM, Node.js, Go) now read the cgroup limits; check yours does, or tell it its heap size.

docker run --rm --memory 32m --memory-swap 32m python:3.15-slim \
  python -c "x = bytearray(200 * 1024 * 1024)"
echo $?                    # 137: killed by the OOM killer
docker stats --no-stream   # current usage against each limit

What to learn

  • --memory, --memory-swap, --cpus, --pids-limit
  • Limits in Compose (deploy.resources.limits)
  • Recognising OOM kills: exit code 137 and OOMKilled in docker inspect
  • How language runtimes size their heaps from cgroup limits
  • Disk: log growth, image clean-up and docker system df

Free resources

Practice

Load-test your app with a memory limit and watch docker stats. Find the lowest limit at which it survives a realistic load, set the limit 30–50% above that, and confirm an OOM kill shows up as exit code 137 with OOMKilled=true.

Logging and monitoring containers

Containers should write logs to stdout and stderr and let Docker collect them. The default json-file driver keeps everything forever unless you set a size limit, which is a classic cause of full disks. Set max-size and max-file, or use the local driver, per container or for the whole daemon in /etc/docker/daemon.json. Ship logs to a central system and collect metrics with tools such as cAdvisor and Prometheus.

docker run -d --name app --log-opt max-size=10m \
  --log-opt max-file=3 myapp:1.0
docker inspect -f '{{json .HostConfig.LogConfig}}' app
# {"Type":"json-file","Config":{"max-file":"3","max-size":"10m"}}

What to learn

  • Log to stdout/stderr; structured (JSON) log lines
  • Logging drivers (json-file, local, journald, fluentd…) and rotation options
  • Daemon-wide defaults in daemon.json
  • Container metrics: docker stats, cAdvisor, the Docker Engine Prometheus endpoint
  • Shipping logs and metrics to Loki, Elasticsearch or a cloud service

Free resources

Practice

Set daemon-wide log rotation, start a container that logs a line every millisecond and check the log files stay within the limit. Then run cAdvisor and Prometheus with Compose and graph your app's memory use.

Running containers in production on a server

Many apps run happily on one or a few servers with Docker Compose. A production setup adds: images pulled from a registry by version (never built on the server), restart policies, resource limits, log rotation, a reverse proxy that terminates HTTPS (Caddy, Traefik or nginx), secrets from outside the image, backups of every volume, and a simple, repeatable way to update.

# compose.prod.yaml
services:
  web:
    image: ghcr.io/acme/myapp:1.4.2
    restart: unless-stopped
    read_only: true
    tmpfs:
      - /tmp
    deploy:
      resources:
        limits:
          cpus: "1.0"
          memory: 512M
    logging:
      driver: local
      options:
        max-size: 10m
        max-file: "3"

  proxy:
    image: caddy:2.11
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy-data:/data
    depends_on:
      - web

volumes:
  caddy-data:
# Caddyfile: automatic HTTPS for your domain
example.com {
	reverse_proxy web:8000
}

What to learn

  • Compose in production: separate files, pinned image versions, restart, limits, logging
  • A reverse proxy with automatic HTTPS in front of your containers
  • Updating: docker compose pull then up -d, and how to roll back
  • Backups and restores of volumes and databases, tested
  • Host basics: firewall (remember published ports bypass ufw), updates, Docker started by systemd

Free resources

Practice

Deploy your app to a small cloud VM with Compose and Caddy on your own (sub)domain with HTTPS. Write a one-page runbook for updating, rolling back and restoring the database from backup, then do each of them once.

Docker Swarm basics

Swarm mode is Docker's built-in orchestrator: join a few machines into a swarm and deploy services with replicas, rolling updates, secrets and an overlay network across hosts, using Compose-style stack files (docker stack deploy). It's much simpler than Kubernetes and still maintained, but its ecosystem is small; most teams that outgrow one server move to Kubernetes or a managed container service. Learn it if your company uses it or if you want the Docker Certified Associate exam, which still covers it.

What to learn

  • docker swarm init / join, managers and workers, Raft quorum
  • Services, replicas, docker service scale and rolling updates
  • Stacks from Compose files, overlay networks and the routing mesh
  • Swarm secrets and configs

Free resources

Practice

On three small VMs (or Play with Docker), create a swarm, deploy your Compose app as a stack with three web replicas, do a rolling update to a new image tag and shut down one node to watch the replicas move.

From Docker to Kubernetes

When you need many servers, self-healing, autoscaling and zero-downtime deploys across a team, the usual next step is Kubernetes (or a managed service such as ECS, Cloud Run or Azure Container Apps). Your images carry over unchanged; what changes is how you describe running them. A Compose service maps roughly to a Deployment plus a Service, volumes to PersistentVolumeClaims, environment to ConfigMaps and Secrets, and health checks to probes. Kubernetes doesn't use Docker Engine to run containers; it talks to containerd or CRI-O directly, and that's fine because the images are OCI images.

What to learn

  • When one server with Compose is enough, and when it isn't
  • Mapping Compose concepts to Kubernetes objects
  • Why "Kubernetes removed Docker" (dockershim) didn't break your images
  • Running a local cluster (kind, minikube, k3d, or Docker Desktop's built-in one)
  • Converting a Compose file as a starting point (Kompose), then cleaning it up by hand

Free resources

Practice

Run your Compose app on a local kind cluster: write a Deployment, Service and ConfigMap for the web service by hand, use a managed or Helm-installed database, and compare the YAML with what Kompose generates.

Alternatives: Podman, containerd, Buildah and Rancher Desktop

Docker isn't the only way to build and run OCI containers. Podman is daemonless and rootless by default, with a Docker-compatible CLI (alias docker=podman works for most commands) and support for Compose files and Kubernetes YAML. containerd with nerdctl is the runtime underneath Docker and Kubernetes, usable on its own. Buildah builds images without a daemon. Rancher Desktop and Podman Desktop are free desktop apps for Windows and macOS.

What to learn

  • Podman: daemonless, rootless, pods, podman compose, Quadlet with systemd
  • containerd and nerdctl; CRI-O in Kubernetes
  • Daemonless image builds: Buildah, kaniko-style builds in CI
  • Choosing a desktop: Docker Desktop's licence vs Rancher Desktop and Podman Desktop

Free resources

Practice

Run your app's image with Podman as a normal user, then run its Compose file with podman compose. Note every command or option that behaved differently from Docker.

Capstone: containerise and ship a real app

Bring every stage together on one project you can show in an interview: an app with a web service, a database and a cache, built small and secure, tested and published by CI, and running on a real server with HTTPS.

What to learn

  • A multi-stage Dockerfile with a non-root user, health check and .dockerignore
  • Compose for development (watch, profiles) and a separate production file
  • CI that tests, scans, builds for amd64 and arm64, and pushes with SBOM and provenance
  • A server deployment with HTTPS, limits, log rotation and tested backups
  • A README that explains how to run, update and roll back

Free resources

Practice

Ship it: a public repository with the Dockerfile, Compose files and workflow, an image in a public registry under 150 MB that scans clean of fixable critical issues, and the app live on your domain. Ask someone to clone it and run it with one command.

Am I ready? Stage 4 quiz

A container keeps exiting with code 137. What is the most likely cause?

  1. It was killed with SIGKILL, often by the out-of-memory killer when it went over its memory limit
  2. A syntax error in the Dockerfile
  3. The image wasn't found
  4. It exited normally

137 = 128 + 9 (SIGKILL). Check docker inspect for OOMKilled: true.

Which kernel feature limits how much memory a container can use?

  1. Namespaces
  2. OverlayFS
  3. cgroups
  4. seccomp

Namespaces control what a process can see; cgroups control how much it can use.

A server's disk fills up after a few weeks. /var/lib/docker/containers is huge. What's the fix?

  1. Restart the containers every week
  2. Set log rotation (max-size, max-file) or use the local logging driver
  3. Switch the storage driver
  4. Delete /var/lib/docker while Docker is running

The default json-file driver keeps logs without limit unless you configure rotation.

You publish a container port with -p 5432:5432 on a server where ufw blocks 5432. Is the database reachable from the internet?

  1. No, ufw always wins
  2. Only over IPv6
  3. Only if the container runs as root
  4. Yes: Docker adds its own firewall rules that bypass ufw; bind to 127.0.0.1 or don't publish it

Docker's iptables/nftables rules handle published ports before ufw's rules see the traffic.

Kubernetes no longer uses Docker Engine to run containers. What does that mean for your Docker-built images?

  1. Nothing: they are OCI images, which containerd and CRI-O run directly
  2. They must be rebuilt with Podman
  3. They only run on Docker Desktop's Kubernetes
  4. You must convert them with Kompose

Only the dockershim adapter was removed. The image format is a shared standard.

How to use this roadmap

  • Type the examples yourself. Every command, Dockerfile and Compose file on this page was run on Docker Engine 29 before publishing (the GitHub Actions workflow was checked against the actions' current versions). In the command examples, everything after # is an explanation or the output you should see, not part of the command. Where an example uses myapp:1.0, build your own app's image first.
  • Use the filter. Developer is for people who build apps in containers: Dockerfiles, Compose, builds, debugging and CI. DevOps & production is for people who run them: limits, logging, servers, registries and orchestration. Security & supply chain focuses on least privilege, secrets, scanning, SBOMs, signing and runtime security. The labels are a guide, not an official exam outline.
  • Certification is optional. Docker certification is run by Mirantis, which bought Docker's enterprise business in 2019. The Docker Certified Associate (DCA) exam is still offered (at the time of writing 55 questions in 90 minutes, US$199; see the Mirantis DCA page for current details), and it still covers Swarm and enterprise features. Most employers care more about a project you can show, like the capstone.
  • It's free to follow. Docker Engine, Compose, Buildx, Podman, Trivy and every resource linked here are free. Docker Desktop is free for personal use, education, open source and small businesses (under 250 employees and US$10 million revenue); larger companies need a paid plan or a free alternative.
  • Watch for outdated guides. If a tutorial uses docker-compose with a hyphen, a version: line at the top of the Compose file, links:, MAINTAINER, or builds without BuildKit, it was written before 2023. The ideas still apply; the syntax has moved on.
  • Track your progress. Ticking the first item in a topic marks it in progress; ticking them all marks it done. Progress stays in this browser. Use Export to move it to another device, or Share progress to send a link. Optional topics (dashed borders) don't count towards the percentage.
  • Related roadmaps: learn the shell first with Linux & Shell, put containers into pipelines with DevOps, orchestrate them with Kubernetes, run them on AWS (ECR and ECS), provision servers with Terraform, build the apps inside them with Backend and Python, and secure them with Web Security.

Docker command cheat sheet

Rundocker run -d --name web -p 127.0.0.1:8080:80 nginx:1.30-alpine · topic
List / logs / shelldocker ps -a, docker logs -f web, docker exec -it web sh · topic
Stop and removedocker stop web, docker rm web, or docker rm -f web
Build and tagdocker build -t myapp:1.0 . · topic
Pushdocker tag myapp:1.0 ghcr.io/me/myapp:1.0, docker push ghcr.io/me/myapp:1.0 · topic
Volumesdocker volume create data, -v data:/var/lib/postgresql · topic
Networksdocker network create appnet, --network appnet · topic
Composedocker compose up -d --wait, logs -f, exec, down · topic
Multi-platformdocker buildx build --platform linux/amd64,linux/arm64 --push . · topic
Limits--memory 512m --cpus 1 · topic
Least privilege--user 10001 --read-only --cap-drop ALL --security-opt no-new-privileges · topic
Clean updocker system df, docker system prune (add --volumes only if you mean it)

Check Dockerfiles and Compose files with the Docker validator, convert environment files with the .env converter, build CI workflows with the GitHub Actions builder and work out file modes with the chmod calculator; all of them run in your browser and send nothing anywhere. Product and service names are examples, not endorsements. Docker and the Docker logo are trademarks of Docker, Inc.; DevToolbox is not affiliated with Docker, Inc. Facts and links on this page were checked on 5 November 2026.