Opscraft
Containers

Docker Compose

Must-know10 lessons · 31 min · 3 tests ·

Docker Compose describes a multi-container application — services, networks, volumes, secrets — in one YAML file and runs it with one command on a single Docker host. It's the standard for local development environments and for spinning up real dependencies (databases, queues, caches) in CI integration tests. Interviewers use it to check that you understand service discovery, startup ordering and health, environment configuration, and when Compose stops being the right tool.

Stage 2 · Core tools

Know these first

After this topic you can

  • Describe a multi-container app in one Compose file
  • Manage dependencies, health checks and volumes
  • Use Compose for local development and CI

Lessons

  1. 1What Compose is and how it organises things 3 min read
    • Compose V2 and the Compose Specification
    • File discovery
    • The project
    • Top-level sections
  2. 2Defining services 4 min read
    • A realistic file
    • Key service options
    • build and image together
  3. 3Variables and configuration 3 min read
    • Two different kinds of "environment"
    • Interpolation syntax
    • Precedence for container environment
    • Secrets
  4. 4Networking between services 3 min read
    • The default network and service discovery
    • Custom networks and isolation
    • Reaching the host from a container
  5. 5Volumes and data 3 min read
    • Named volumes vs bind mounts in Compose
  6. 6Startup order, health and readiness 3 min read
    • depends_on only orders starts by default
    • Conditions
    • Still build resilience into the app
  7. 7Multiple environments: overrides, profiles, extends 3 min read
    • Override files
    • Profiles
    • Reuse: anchors, extends, include
  8. 8Everyday commands and workflows 3 min read
    • Scaling
    • Compose in CI integration tests
  9. 9Production use, Kubernetes migration and troubleshooting 3 min read
    • Is Compose OK in production?
    • Mapping Compose to Kubernetes
    • Troubleshooting
  10. 10Interview questions and model answers 3 min read
    • "How do services find each other in Compose?"
    • "depends_on is set but my app still fails because the database isn't ready. Why, and how do you fix it?"
    • "How do you handle dev, CI and prod differences with one Compose setup?"
    • "What's the difference between .env, env_file and environment?"
    • "Would you use Compose in production?"
    • "--scale worker=3 fails. Why?"
    • "How do you use Compose in a CI pipeline?"