Docker Compose

Run multi-container apps with Docker Compose: services and builds, environment and interpolation, health checks and startup order, volumes, secrets, networks, override files and profiles, with every configuration checked by docker compose config.

Start course →

What you'll learn

  • Describe multi-container applications in a Compose file with services, builds, ports and environment.
  • Use .env files, interpolation, required variables and YAML anchors, and validate files before running.
  • Order startup with health checks and depends_on conditions, and choose restart policies.
  • Persist data with named volumes, mount code with bind mounts, and pass secrets as files.
  • Isolate traffic with networks and expose only what is needed.
  • Manage development and production differences with override files, -f and profiles.

Syllabus

Compose Fundamentals

  1. What Docker Compose Is For
  2. Anatomy of a Compose File
  3. The Compose Lifecycle

Defining Services

  1. image Versus build
  2. Ports and Exposure
  3. Environment Variables and YAML Anchors

Interpolation, .env Files and Validation

  1. Interpolation and the .env File
  2. Required Variables
  3. Environment Precedence Inside Containers
  4. Validating With docker compose config

Startup Order, Health and Restarts

  1. depends_on With Conditions
  2. Health Checks
  3. Restart Policies

Volumes, Bind Mounts and Secrets

  1. Named Volumes Versus Bind Mounts
  2. Secrets as Files
  3. Backing Up and Resetting Data

Networks

  1. The Default Network and Service Names
  2. Custom and Internal Networks
  3. Exposure and Security

Development, Production and Profiles

  1. compose.override.yaml for Development
  2. Production Files With -f
  3. Profiles for Optional Services

Workflows, Limits and a Checklist

  1. A Smooth Development Workflow
  2. Compose in Production and When to Move On
  3. A Compose File Review Checklist