Chapter 7: Docker Volumes, Networks and Compose
7.8b Compose project layout for badge API
Keep the Compose file next to the Dockerfile so build: . is obvious:
badge-api/
Dockerfile
.dockerignore
.env.example
.env # gitignored
compose.yaml
app.py / index.js
requirements.txt / package.json
Profiles (awareness). Compose profiles can mark optional services (for example a debug Redis). Skip advanced profiles until the basic api+db stack is boringly reliable.
Restart policies.
services:
api:
restart: unless-stopped
Useful on a lab VM that reboots — still not a substitute for a real orchestrator (Kubernetes comes later).
Override files. compose.override.yaml can hold laptop-only bind mounts. Do not commit machine-specific absolute paths that only work on one classmate's laptop.
What you see in a tidy repo: docker compose config prints the merged YAML without errors; secrets stay out of that printout if you used env substitution carefully.
Ravindra Bagale's Tip
docker compose config ne YAML merge bagha — indentation chuk catch hote. Apply agodar validate. Dhyan rakho!