Docker and CI/CD · Junior · Question 24 of 75
In Compose, how does the app service connect to the db service?
- 1Through
localhost:5432, as both share one host - ✓Correct answer: By the service name, e.g.
postgres://db:5432 - 3Through the container's IP from
docker inspect
Explanation
Compose puts services on a shared network with built-in DNS, so the service name resolves to the right container. IPs change between runs; names don't.