Docker Networks
44%
User-Defined Bridge Networks
In addition to the default bridge network, you can create your own bridge network and attach containers to it.
To create our own bridge network, use the following command:
docker network create my_bridge_network
# This is equivalent to:
# docker network create --driver bridge my_bridge_network
# since bridge is the default driver
Create two busybox containers attached to the network my_bridge_network:
# Create two containers busybox1 and busybox2 on the user-defined bridge network
docker run -it -d --name busybox1 \
--network my_bridge_network busybox
docker run -it -d --name busybox2 \
--network my_bridge_network busybox
# Ping using container names should succeed now
docker exec -it busybox1 ping -c1 busybox2
docker exec -it busybox2 ping -c1 busybox1
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.
Unlock now  $31.99$25.59Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
