Docker Compose — Compose Config & Validate
Use docker compose config as your first debugging tool — it validates YAML, resolves variables, and shows the effective configuration.
Validate Only
docker compose config -q
No output = valid. Errors show the problem line.
Show Resolved Config
docker compose config
Shows the fully resolved compose file with:
- Variables substituted
- Override files merged
- Extensions expanded
- Defaults applied
Specific Inspections
docker compose config --services # List all service names
docker compose config --volumes # List all volume names
docker compose config --images # List all images
docker compose config --profiles # List all profiles
Dry Run (Compose v2.24+)
Test what would happen without actually doing it:
docker compose up --dry-run
docker compose down --dry-run
Output shows what Compose would do:
DRY-RUN MODE - Would create network myapp_default
DRY-RUN MODE - Would create container myapp-db-1
DRY-RUN MODE - Would create container myapp-api-1
DRY-RUN MODE - Would start container myapp-db-1
DRY-RUN MODE - Would start container myapp-api-1
Compare Configurations
# Save current config
docker compose config > /tmp/before.yml
# Make changes...
# Save new config
docker compose config > /tmp/after.yml
# Compare
diff /tmp/before.yml /tmp/after.yml
Verify Variable Substitution
# Show which variables are used
docker compose config | grep -E '\$\{|WARNING'
# If you see warnings about unset variables:
docker compose config 2>&1 | grep WARN
Hash Check
docker compose config --hash="*"
Shows a hash for each service config — useful to detect if a service needs recreation.
Debugging Checklist
docker compose config -q— Fix any YAML errorsdocker compose config— Verify resolved valuesdocker compose config --services— Verify service namesdocker compose up --dry-run— Test the plandocker compose up -d— Execute
Summary
| Command | Purpose |
|---|---|
config -q |
Validate only (quiet) |
config |
Show resolved configuration |
config --services |
List service names |
config --images |
List image references |
up --dry-run |
Preview actions |
config --hash=* |
Detect config changes |
Quick Reference
| Item | Detail |
|---|---|
| config -q | Validate YAML syntax |
| config | Show fully resolved file |
| –services | List service names |
| –dry-run | Preview without executing |
| –hash | Detect config changes |