Skip to content

Instantly share code, notes, and snippets.

@koolquark
Last active June 19, 2018 18:07
Show Gist options
  • Save koolquark/f680d9ddbffa0961d1e7b6ae990eec9c to your computer and use it in GitHub Desktop.
Save koolquark/f680d9ddbffa0961d1e7b6ae990eec9c to your computer and use it in GitHub Desktop.
Docker Custom Bridge
# List netwoks
docker network ls
# Prune un-necessary networks
docker network prune
# Create a custom bridge network
# See man docker-network-create
docker network create \
--driver=bridge\
--subnet=172.28.0.0/22 \
--ip-range=172.28.0.0/23 \
--gateway=172.28.0.1 \
devbr
docker run -dit --name alpine1 --network devbr alpine ash
docker run -dit --name alpine2 --network devbr alpine ash
docker run -dit --name alpine3 alpine ash
docker network connect devbr alpine3
docker attach alpine1
ip addr show
ping -c 2 172.28.0.1
ping -c 2 172.28.0.2
ping -c 2 172.28.0.3
# From OS
ifconfig -a | grep 172.27.0.1
# Ping from OS to docker vm
ping -c 2 172.28.0.3 # This also pings successfully
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment