Which Compose features do you use for local dev vs production?
IntermediateScenarioNetworking and Compose
Answer
Situation read → Same services, different needs.
What I'd do → Base compose.yaml holds services; compose.override.yaml (auto-loaded) adds bind mounts, debug ports and develop.watch; compose.prod.yaml sets restart: unless-stopped, resource limits and no bind mounts: docker compose -f compose.yaml -f compose.prod.yaml up -d. Use profiles for optional tools.
Why → Layered files avoid duplication.
Interview tip → docker compose config shows the merged result.
More on Networking and Compose
Containers on the default bridge cannot resolve each other by name. Why, and what do you do?BeginnerHow do you expose a container only to the local host, not the internet?BeginnerDesign a Compose file for web + api + postgres + redis with correct startup ordering.IntermediateFrontend must reach the API but not the database. Segment the network.IntermediateA container needs to call a service running on the Docker host.BeginnerWhen would you use `--network host`?Intermediate