Skip to content

The Default Bridge Network

When the Docker daemon starts, it creates a virtual Ethernet switch called docker0 on the host. This is the default bridge network. Every container that you start without specifying --network is connected to docker0 automatically.

Containers on the default bridge receive an IP address from the 172.17.0.0/16 subnet. The gateway — and the host itself — sits at 172.17.0.1.

flowchart TB
  host["Host"]
  bridge["docker0 (172.17.0.1)"]
  c1["container c1 (172.17.0.2)"]
  c2["container c2 (172.17.0.3)"]
  host --> bridge
  bridge --> c1
  bridge --> c2
Containers attached to the default docker0 bridge

Running two containers and inspecting their IPs

Section titled “Running two containers and inspecting their IPs”

Start an nginx container named c1 and an Alpine container named c2:

Terminal window
docker run -d --name c1 nginx:alpine
docker run -d --name c2 alpine sleep 300

Inspect the IP address assigned to each container:

Terminal window
docker inspect c1 --format '{{.NetworkSettings.IPAddress}}'
docker inspect c2 --format '{{.NetworkSettings.IPAddress}}'

You will see addresses like 172.17.0.2 and 172.17.0.3.

Because both containers are on the same docker0 bridge, layer-3 routing between them works. From c2, ping c1 by its IP address:

Terminal window
docker exec c2 ping -c 3 172.17.0.2

The ping succeeds. Traffic flows through docker0 on the host.

Container name resolution does NOT work on the default bridge

Section titled “Container name resolution does NOT work on the default bridge”

Now try the same ping using the container name instead of the IP:

Terminal window
docker exec c2 ping c1

This fails with bad address 'c1' or a similar DNS error. The default bridge network does not include an embedded DNS resolver, so container names are not resolvable. Only user-defined networks (covered in the next lesson) provide automatic DNS.

Stop and remove both containers when you are done:

Terminal window
docker stop c1 c2
docker rm c1 c2
# Start two containers on the default bridge
docker run -d --name c1 alpine sleep 300
docker run -d --name c2 alpine sleep 300

# Find their IPs
C1_IP=$(docker inspect c1 --format '{{.NetworkSettings.IPAddress}}')
C2_IP=$(docker inspect c2 --format '{{.NetworkSettings.IPAddress}}')
echo "c1 IP: $C1_IP"
echo "c2 IP: $C2_IP"

# Ping c2 from c1 by IP (succeeds)
docker exec c1 ping -c 3 $C2_IP

# Try to ping by name (fails — no DNS on default bridge)
docker exec c1 ping -c 1 c2 || echo "Name resolution failed as expected"

# Cleanup
docker stop c1 c2 && docker rm c1 c2
What subnet does the Docker default bridge network use for container IP addresses?
Why does pinging a container by name fail on the default bridge network?
What is the name of the virtual Ethernet switch Docker creates for the default bridge network?
Two containers are on the default bridge network. Which of the following statements is true?