Containers
Docker Compose
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.
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
-
1What Compose is and how it organises things
- Compose V2 and the Compose Specification
- File discovery
- The project
- Top-level sections
-
2Defining services
- A realistic file
- Key service options
- build and image together
-
3Variables and configuration
- Two different kinds of "environment"
- Interpolation syntax
- Precedence for container environment
- Secrets
-
4Networking between services
- The default network and service discovery
- Custom networks and isolation
- Reaching the host from a container
-
5Volumes and data
- Named volumes vs bind mounts in Compose
-
6Startup order, health and readiness
- depends_on only orders starts by default
- Conditions
- Still build resilience into the app
-
7Multiple environments: overrides, profiles, extends
- Override files
- Profiles
- Reuse: anchors, extends, include
-
8Everyday commands and workflows
- Scaling
- Compose in CI integration tests
-
9Production use, Kubernetes migration and troubleshooting
- Is Compose OK in production?
- Mapping Compose to Kubernetes
- Troubleshooting
-
10Interview questions and model answers
- "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?"