DevOps Classroom Series – 04/Feb/2020

Docker Network Drivers

  • Docker networking way back was part of docker daemon

  • Docker networking is implemented as a different component libnetwork

  • Networking in Docker is implemented as Network Drivers. Popular drivers are

    • Bridge
    • Host
    • MACVLAN
    • None
    • Overlay (multi host)
  • Refer for Networking Series-1

  • Refer for Networking Series – 2 (Multihost)

  • Refer Here for official docker network docs

Creating a new bridge network

  • Create a new bridge network with range as 10.11.0.0/16 and name as mybridge
docker network create --driver bridge --subnet 10.11.0.0/16 mybridge

docker network ls

docker network inspect mybridge
  • Create two container p1 and p2 on the mybridge
docker container run --name p1 --network mybridge -d alpine sleep 1d

docker container run --name p2 --network mybridge -d alpine sleep 1d
  • Now test for the connectivity between p1 and p2 using ip and hostnames
docker network inspect mybridge
# make a note of ip addresses
docker exec p1 ping -c 3 10.11.0.3

docker exec p1 ping -c 3 p2
  • In the above both containers can connect using names and ip addresss
  • Try to add container c1 which is running in bridge network to mybridge network
docker network connect mybridge c1

docker network inspect mybridge


docker exec p1 ping -c 3 c1

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin