Docker Compose
Docker Compose describes a multi-container development environment as one file in the repository, started with docker compose up. The lessons use a Rails application and its PostgreSQL database. They cover the current file format without the obsolete version key, service names as hostnames, and health checks that wait for readiness. They also cover named volumes and bind mounts, configuration and secrets kept out of the repository, and everyday commands. The course ends with a complete compose.yaml for the app and the five failures that cost the most time.
What you'll learn
- ✓Writing a compose.yaml with services, images, builds and YAML anchors
- ✓How services find each other by name and when to publish ports
- ✓Using health checks so depends_on waits for readiness
- ✓Choosing between named volumes and bind mounts, and the problems each one brings
- ✓Keeping secrets out of the repository with .env, interpolation and Compose secrets
- ✓Daily commands: exec, run, profiles, watch and docker compose config
One container is not an environment
The previous course ended with an image that runs this application. That is one process. A working environment for this app is at least two, because the app needs PostgreSQL, and a realistic one adds a job worker and sometimes more.
Read the full lesson free →Curriculum
7 lessonsOne container is not an environment
Why hand-run containers need a file, what Compose covers on one machine, and why compose.yaml is preferred.
Services, images, and what changed
The obsolete version key, top-level elements, build versus image, command overrides, binding to 0.0.0.0 and YAML anchors.
Networking and start order
Service names as hostnames, published ports, and health checks that make depends_on wait for readiness instead of start.
Data that survives
Named volumes and bind mounts, how a bind mount hides image files, Linux permissions, and the destructive down -v.
Configuration and secrets
Configuration sources and precedence, required-variable interpolation, .env and .env.example, Compose secrets and override files.
Working in it day to day
Everyday commands, exec versus run, profiles, watch rebuilds, diagnosing with docker compose config, and freeing disk space.
A Compose file for this app
A complete compose.yaml for this app, how it starts, the five common failures, and where Compose fits.