Free tutorial · 26 lessons

Docker Tutorial

Learn Docker from your first container to production-ready images: images and layers, the container lifecycle, Dockerfiles, build caching, multi-stage builds, base images, volumes, networks, ports, Docker Compose with healthchecks and profiles, and security, resource limits and cleanup. Every example is a real shell script run against Docker Engine, with the output it printed.

Start learning →

Docker Basics

  1. What Is Docker? — What containers are, why Docker made them popular, and how containers differ from virtual machines.
  2. Running Containers — docker run in practice: foreground and background containers, names, removing containers and passing commands.
  3. Images and Layers — Pull images, list them, and see how images are made of shared, read-only layers.
  4. The Container Lifecycle — Create, start, stop, restart and remove containers, and what happens to their files along the way.
  5. Logs, exec and inspect — Read a container's output, run commands inside it, and inspect its configuration while it runs.
  6. Docker History & Versions — Where Docker came from, how containers went from a PaaS company's internal tool to the standard way to package software, the open standards that followed, and which versions are current.

Building Images

  1. Writing a Dockerfile — The Dockerfile instructions you need for most images: FROM, WORKDIR, COPY, RUN, ENV, EXPOSE and CMD.
  2. Layer Caching and Fast Builds — Order Dockerfile instructions so dependency installs are cached and code changes rebuild in seconds.
  3. The Build Context and .dockerignore — Keep secrets, Git history and local junk out of the build context and out of your images.
  4. Multi-Stage Builds — Build with full toolchains, ship only the result: small, safer images with multi-stage Dockerfiles.
  5. Choosing a Base Image — Full, slim, Alpine and distroless base images: size, compatibility and security trade-offs.
  6. CMD vs ENTRYPOINT — How ENTRYPOINT and CMD combine, shell form versus exec form, and why it matters for signals.
  7. Build Arguments and Environment Variables — ARG for build-time values, ENV for runtime configuration, and why secrets belong in neither.
  8. Tags, Digests and Registries — Name, tag and push images, and pin exactly what you run with digests.

Data and Networking

  1. Volumes: Keeping Data — Container filesystems are temporary; named volumes keep databases and uploads across container replacements.
  2. Bind Mounts for Development — Mount source code or configuration from the host into a container, read-only where possible.
  3. Container Networks and DNS — How containers talk to each other: user-defined bridge networks with built-in DNS by container name.
  4. Publishing Ports — Make a container reachable from the host and the outside world with -p, and bind to localhost when you mean it.

Docker Compose

  1. Docker Compose Basics — Describe a multi-container app in compose.yaml and run it with one command.
  2. Startup Order and Healthchecks — depends_on only orders startup; use healthchecks and condition: service_healthy to wait until a service is ready.
  3. Environment Files, Profiles and Overrides — Configure Compose per environment with .env files, variable interpolation, profiles and override files.

Production Practices

  1. Non-Root Users and Read-Only Containers — Reduce what a compromised container can do: run as a non-root user, use a read-only filesystem and drop capabilities.
  2. Memory and CPU Limits — Limit memory and CPU so one container can't starve the host, and recognise out-of-memory kills.
  3. Healthchecks and Restart Policies — Let Docker detect unhealthy containers and restart crashed ones automatically.
  4. Disk Usage and Cleanup — Images, build cache and stopped containers fill disks quietly; see where space goes and reclaim it safely.
  5. Where to Go Next — Production courses, Kubernetes, and practice for what you've learned about Docker.

Was this page helpful?