Compose Configuration in Docker
From the Docker cheat sheet ยท Docker Compose ยท verified Jul 2026
Compose Configuration
Full compose.yml reference with depends_on, healthcheck, profiles, watch, and more
yaml
services:
app:
build: .
ports:
- "3000:3000"
depends_on:
db:
condition: service_healthy
environment:
DATABASE_URL: postgres://user:pass@db:5432/mydb
db:
image: postgres:17-alpine
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
volumes:
db-data:๐ก depends_on with condition: service_healthy waits until the dependency passes its healthcheck
โก Compose Watch syncs files without rebuilding โ use action: sync for source, action: rebuild for deps
๐ Profiles let you define optional services (debug tools, admin panels) that only start when requested
๐ข Use env_file to load .env files โ keeps secrets out of compose.yml and version control