IntermediateLesson 11 of 26
Compose in practice
Health-based startup, profiles, overrides and rebuilds.
depends_on only controls start order. To wait until a service is actually ready, combine it with a healthcheck.
yaml
services:
db:
image: postgres:16
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 5s
retries: 10
web:
build: .
depends_on:
db:
condition: service_healthy
profiles: ['app'] # only starts with --profile appcompose.override.yamlis merged automatically: put dev-only settings there.docker compose up --buildrebuilds images;docker compose watchsyncs code changes.