Interview Prep/Docker/Networking and Compose

Containers on the default bridge cannot resolve each other by name. Why, and what do you do?

BeginnerScenarioNetworking and Compose
Answer

Situation read → The default bridge network has no embedded DNS for container names.

What I'd do →

docker network create appnet
docker run -d --network appnet --name db postgres:17
docker run -d --network appnet --name api myapi   # reach db at db:5432

Compose does this automatically with a per-project network.

Why → User-defined bridges provide automatic service discovery and better isolation.

Interview tip → --link is legacy; do not use it.

All Docker questions Roadmap: Docker & containers

More on Networking and Compose