0
0
Dockerdevops~10 mins

Bridge network default behavior in Docker - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Bridge network default behavior
Docker daemon starts
Create default bridge network
Container connects to bridge
Assign container IP from bridge subnet
Enable container communication via bridge
Enable NAT for external access
Container can communicate internally and externally
Docker creates a default bridge network at startup. Containers connected to it get IPs and can talk to each other and outside via NAT.
Execution Sample
Docker
docker network ls
docker run -d --name c1 nginx
docker inspect c1
ping <container_ip>
List networks, run a container on default bridge, inspect IP, and ping to test connectivity.
Process Table
StepActionResultNetwork State
1Docker daemon startsDefault bridge network 'bridge' createdbridge network exists with subnet 172.17.0.0/16
2Run container c1 without network optionContainer connected to default bridgec1 assigned IP 172.17.0.2
3Inspect container c1Shows IP 172.17.0.2 and bridge networkbridge network has 1 container connected
4Run container c2Connected to default bridgec2 assigned IP 172.17.0.3
5Ping c2 from c1Ping successfulContainers communicate internally via bridge
6Container c1 accesses internetAccess allowed via NATBridge network performs NAT for outbound traffic
7Stop container c1Container removed from bridgebridge network has 1 container connected
8Remove container c2No containers connectedbridge network empty
9ExitNo more containers connectedbridge network remains available
💡 No more containers connected, default bridge network remains active for future use
Status Tracker
VariableStartAfter Step 2After Step 4After Step 7After Step 8
bridge networkCreated with subnet 172.17.0.0/161 container connected (c1)2 containers connected (c1, c2)1 container connected (c2)0 containers connected
Key Moments - 3 Insights
Why does the container get an IP address automatically?
Because the container connects to the default bridge network which assigns IPs from its subnet automatically, as shown in execution_table step 2 and 4.
Can containers on the default bridge communicate with each other?
Yes, containers connected to the default bridge can communicate internally, demonstrated by the successful ping in step 5.
How does a container access the internet if connected to the default bridge?
The default bridge network uses NAT (Network Address Translation) to allow containers to access external networks, shown in step 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what IP address is assigned to container c1 after step 2?
A172.17.0.2
B172.17.0.3
C192.168.1.2
D10.0.0.2
💡 Hint
Check the 'Result' column in row for step 2 in the execution_table.
At which step do containers first communicate with each other?
AStep 3
BStep 5
CStep 6
DStep 4
💡 Hint
Look for the 'Ping successful' action in the execution_table.
If container c1 is removed, how many containers remain connected to the bridge network?
A0
B2
C1
DNone, network is deleted
💡 Hint
Check the 'Network State' column after step 7 in the execution_table.
Concept Snapshot
Docker default bridge network:
- Created automatically at Docker start
- Assigns IPs to containers from 172.17.0.0/16
- Enables container-to-container communication
- Provides NAT for internet access
- Network persists even if no containers connected
Full Transcript
When Docker starts, it creates a default bridge network named 'bridge'. Containers run without specifying a network connect to this bridge automatically. Each container gets an IP address from the bridge subnet, typically 172.17.0.x. Containers connected to this bridge can communicate with each other directly. The bridge network also provides NAT so containers can access the internet. Even if all containers stop or are removed, the default bridge network remains available for future containers.