Docker Tutorial with Examples.
Docker tutorial for beginners: containerise applications, build optimised images, configure networking and orchestrate with Docker Compose.
Architecture at a glance
Click any box to open the lesson that teaches it
Docker architecture at a glance
Dockerfile → build → image → registry → docker run → container
How it fits together (7 steps)
- Write a Dockerfile and build it. Docker reuses a cached layer only while the instruction and everything before it are unchanged, so slow steps that don't depend on your source (dependency installs) go before the
COPYof your code. - A multi-stage build compiles in a full toolchain stage, then copies only the finished artifact into a small runtime stage — a Go binary goes from 287MB to 2.3MB this way.
- Push the image to a registry and sign its digest with cosign so a puller verifies the digest, not a movable tag.
docker runstarts a container that is just a host process: its main command runs as PID 1, sodocker stopsends SIGTERM and only falls back to SIGKILL after the grace period.- A running container uses volumes or bind mounts for data that outlives it, a user-defined bridge network for DNS and published ports, and environment variables for config.
- Multiple services are defined once in docker-compose.yml and brought up together, with health checks gating dependent services.
- Secure and ship it: run as non-root and drop capabilities, pass a CIS Docker Benchmark scan, manage background jobs and signals from the shell, add health checks, limits and a restart policy for production, and deploy real apps with FastAPI on Kubernetes or a Dockerized Spring Boot jar.
Beginner
Start here — no prior experience needed
Introduction to Docker
Run your first Docker containers and see what they are: ordinary Linux processes sharing the host kernel, started from an image in well under a second.
Docker Images and Dockerfiles
Write a Dockerfile, build and run your own image, order layers for the build cache, use ENTRYPOINT, CMD, ARG and .dockerignore, and push to a registry.
Managing Docker Containers
Run, inspect, stop and remove containers: the lifecycle, port publishing, exec, logs, docker stop versus SIGKILL, memory limits and docker cp.
Intermediate
For developers with core concepts down
Docker Networking
Connect containers by name on user-defined bridge networks, see network isolation, aliases, the host and none drivers, and reach the host from a container.
Docker Volumes and Storage
Keep data beyond a container's life with named volumes, bind mounts and tmpfs: sharing, read-only mounts, backup and restore, and permission fixes.
Docker Compose
Define and run multi-container applications with Docker Compose. Services, networks, volumes, and environment configuration.
Advanced
Production-grade patterns for experienced engineers
Multi-Stage Builds
Use multi-stage Dockerfiles to produce small, secure production images by separating build and runtime environments.
Docker Security
Harden Docker images and containers: non-root users, read-only filesystems, secrets management, image scanning, and runtime policies.
Docker in Production
Health checks that actually flip unhealthy, a container OOM-killed for real, log rotation you can see on disk, an authenticated private registry, a measured BuildKit cache-mount speedup, and a real zero-downtime swap.
Also part of Docker
Taught in other topics. Each link opens the lesson in its home topic.
Deploying FastAPI with Docker and Kubernetes: Images, Signals, and Probes
Ship FastAPI on Docker and Kubernetes: a 171 MB multi-stage image, clean SIGTERM shutdown, and liveness, readiness and startup probes on a live minikube.
Dockerizing Spring Boot Applications
Prepare a Spring Boot 3 app for containers: layered jars, env-var config, JVM memory flags, health probes and graceful shutdown, plus a Dockerfile.
Bash Process Management
Run background jobs, manage processes with jobs/fg/bg, send signals with kill, use trap for cleanup, and understand subshells.
CIS Docker Benchmark Checks with docker-bench-security
Run the CIS Docker Benchmark's container checks against a container you start, read each WARN, fix privileged mode and missing limits, and re-run to PASS.
Signing Container Images with Cosign: Verify the Digest, Not the Tag
Sign an image in a local registry with a Cosign key pair, verify it, then push different content under the same tag and watch verification refuse it.