Learn Docker

Build, ship and run applications in portable containers

30 lessons · 6 hours · 4 levels · covers Docker 29

Docker packages an application and everything it needs into an image that runs the same way on a laptop, a CI runner or a production server. It is the standard way to build and run containers, and the foundation for Compose-based development environments and Kubernetes deployments.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics8 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms18 lessons · 3 hours in total
3. AdvancedThe less common features, performance and trade-offs25 lessons · 4 hours in total
4. ExpertInternals and the edge cases experts know30 lessons · 6 hours in total

The Docker tree

DockerContainers vs virtual machinesContainers vs virtualmachinesInstall Docker and run hello-worldInstall Docker andrun hello-worldImages and containersImages andcontainersRunning containers with docker runRunning containerswith docker runManaging containers: ps, logs, exec, stopManaging containers:ps, logs, exec, stopManaging images and disk spaceManaging imagesand disk spaceDockerfile basicsDockerfile basicsBuilding and tagging imagesBuilding and taggingimagesLayers and the build cacheLayers and the buildcacheKeeping the build context lean: .dockerignoreKeeping the buildcontext lean: .dock…Multi-stage buildsMulti-stage buildsPersisting data with volumesPersisting data withvolumesBind mounts and tmpfsBind mounts andtmpfsPublishing portsPublishing portsContainer networkingContainer networkingEnvironment variables and configurationEnvironmentvariables and confi…Docker ComposeDocker ComposeRegistries: pushing and pulling imagesRegistries: pushingand pulling images
Essentials and Practical shown (18 of 30 lessons); the full list is below. Click a lesson to read it.

All 30 lessons, in order

Container basics

  1. Containers vs virtual machines · Essentials · 7 min

    A container is an isolated process sharing the host kernel; a VM runs a whole guest OS on virtual hardware.

  2. Install Docker and run hello-world · Essentials · 8 min

    Install Docker Desktop or Docker Engine, verify it with docker version and run your first container.

  3. Images and containers · Essentials · 9 min

    An image is a read-only template of layers; a container is a running instance of it with its own writable layer.

  4. Running containers with docker run · Essentials · 10 min

    Start containers in the foreground or background, name them, give them a terminal and override their command.

  5. Managing containers: ps, logs, exec, stop · Essentials · 10 min

    List containers, read their logs, open a shell inside them, and stop, restart or remove them.

  6. Managing images and disk space · Essentials · 7 min

    List, tag and remove images, and reclaim disk space with docker system df and prune.

Building images

  1. Dockerfile basics · Essentials · 12 min

    Write a Dockerfile with FROM, WORKDIR, COPY, RUN, ENV, EXPOSE and CMD to package your own app.

  2. Building and tagging images · Essentials · 8 min

    Turn a Dockerfile into an image with docker build, understand the build context, and tag versions properly.

  3. Layers and the build cache · Practical · 12 min

    Each Dockerfile instruction makes a cached layer; order instructions so dependency installs are reused across builds.

  4. Keeping the build context lean: .dockerignore · Practical · 6 min

    List files to exclude from the build context in .dockerignore to speed up builds, improve caching and avoid leaking secrets.

  5. Multi-stage builds · Practical · 12 min

    Use several FROM stages to compile with full toolchains and ship only the result in a small final image.

Storage and data

  1. Persisting data with volumes · Practical · 10 min

    Store data outside a container's writable layer in Docker-managed named volumes that survive container removal.

  2. Bind mounts and tmpfs · Practical · 10 min

    Mount a host directory into a container for live development, or an in-memory tmpfs for scratch data.

Networking and configuration

  1. Publishing ports · Practical · 8 min

    Make a container's service reachable from the host with -p host:container, and bind it to the right interface.

  2. Container networking · Practical · 12 min

    Connect containers on user-defined bridge networks so they reach each other by name via Docker's built-in DNS.

  3. Environment variables and configuration · Practical · 10 min

    Configure containers at run time with environment variables, env files and mounted config, and know ARG from ENV.

Compose and registries

  1. Docker Compose · Practical · 15 min

    Define a multi-container app (services, networks, volumes) in compose.yaml and run it with docker compose up.

  2. Registries: pushing and pulling images · Practical · 10 min

    Push images to Docker Hub or a private registry, authenticate with docker login, and pin by digest.

  3. Compose for real projects · Advanced · 12 min

    Use override files, profiles, health-gated dependencies, interpolation and compose watch to run dev and CI from one setup.

Production readiness

  1. Small and secure images · Advanced · 15 min

    Shrink and harden images: minimal bases, non-root users, pinned versions, no secrets, vulnerability scanning.

  2. Healthchecks and restart policies · Advanced · 10 min

    Tell Docker how to test that your app works with HEALTHCHECK, and how to recover from crashes with restart policies.

  3. Resource limits · Advanced · 10 min

    Cap a container's memory, CPU and process count, and recognise OOM kills.

  4. Debugging containers · Advanced · 14 min

    Diagnose containers that crash, can't connect or have no shell, using logs, inspect, events, exit codes and debug sidecars.

Advanced builds

  1. BuildKit features · Advanced · 14 min

    Use BuildKit's cache mounts, secret and SSH mounts, heredocs and remote cache to make builds faster and safer.

  2. Multi-platform builds · Advanced · 12 min

    Build one image tag for amd64 and arm64 with buildx, using emulation or faster cross-compilation.

Internals and security

  1. Namespaces and cgroups · Expert · 15 min

    Containers are built from Linux namespaces (what a process can see) and cgroups (what it can use).

  2. Union filesystems and overlayfs · Expert · 14 min

    How overlayfs stacks read-only image layers under a writable container layer, with copy-up and whiteouts.

  3. OCI image and runtime specs · Expert · 15 min

    Images are OCI artifacts: content-addressed manifests, configs and layer blobs; runtimes execute an OCI bundle.

  4. Engine architecture: dockerd, containerd, runc · Expert · 12 min

    Follow docker run through the CLI, dockerd, containerd, the shim and runc, and see why each layer exists.

  5. Rootless mode, capabilities and seccomp · Expert · 15 min

    Reduce container privileges with dropped capabilities, seccomp, no-new-privileges, user namespaces and rootless Docker.