Docker Networks
Understanding the Bridge Network
After installing Docker, you might notice a new network interface on your host machine called docker0. You can check for this interface using the ifconfig command:
# Install net-tools if ifconfig is not available
# apt install net-tools
# Run
ifconfig docker0
The docker0 interface typically looks something like this:
docker0: flags=4163 mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::4424:f5ff:fe34:e33e prefixlen 64 scopeid 0x20
ether 46:24:f5:34:e3:3e txqueuelen 0 (Ethernet)
This interface represents the default bridge network that Docker creates on the host machine. Containers connected to this network can communicate with each other using their IP addresses. It's the default network that allows containers to interact unless specified otherwise. Each container connected to this network gets a veth interface on the host machine.
For example, you will have as many veth interfaces as there are running containers:
# Delete all containers first
docker rm -f $(docker ps -aq)
# Run a container1
docker run -d --name my_container_1 nginx
# Check the veth interfaces
ifconfig | grep veth
# Run a container2
docker run -d --name my_container_2 nginx
# Check the veth interfaces again
ifconfig | grep veth
Painless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
