Docker Compose default networking
Compose networking internals.
Compose creates one default user-defined bridge network for the project; all services join it and reach each other by service name via embedded DNS, isolated from other projects.
WHAT THIS TESTS It checks deeper knowledge of what Compose sets up automatically and why service-name resolution works without any explicit network or links.
A GOOD ANSWER COVERS On docker compose up, Compose creates one default network for the project, a user-defined bridge typically named <project>_default, and connects every service to it. The crucial detail is that user-defined bridge networks, unlike Docker's legacy default bridge, include an embedded DNS server, so containers can resolve each other by service name automatically. Each service is also reachable by name, and Compose scopes the network per project so two unrelated projects do not collide or see each other. You only declare networks explicitly when you need segmentation, such as separating a frontend network from a backend network, or connecting to an external network. The deprecated links directive is unnecessary because DNS-based discovery handles it.
COMMON WRONG ANSWERS Saying services share the default bridge network, which lacks automatic DNS resolution. Believing you must use links. Assuming all Compose projects share one flat network. Confusing service name resolution with host networking.
LIKELY FOLLOW-UPS How does a user-defined bridge differ from the default bridge? When would you define multiple networks? How does network scoping isolate projects?
ONE CONCRETE EXAMPLE A project with web, api, and db services and no networks block: Compose creates myproject_default and attaches all three. api connects to db:5432 and web calls api:8000, all resolved by the embedded DNS on that bridge, while a separate project's containers on their own default network remain invisible.
Read the original → docs.docker.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.