Skip to content

Docker Networking Basics

Why containers can’t see each other by name by default

When you run containers without specifying a network, Docker connects them to the default bridge. Each gets its own IP in the 172.17.0.0/16 range.

The catch: the default bridge has no DNS. Containers can reach each other only by IP address.

If you want containers to resolve each other by name (e.g., ping nginx1), create a user-defined network:

docker network create myappnet
docker run -d --name nginx1 --network myappnet nginx
docker run -d --name nginx2 --network myappnet nginx

Now nginx1 can resolve nginx2 automatically — thanks to Docker’s embedded DNS server at 127.0.0.11.

Key Terms

Bridge Network
The default Docker network. Containers can communicate via IP addresses but not names.

User-Defined Network
A custom bridge network with automatic name resolution and isolation from other networks.

Docker DNS (127.0.0.11)
An internal DNS resolver that lets containers in the same user-defined network resolve each other’s names.