Last active
June 19, 2018 18:07
-
-
Save koolquark/f680d9ddbffa0961d1e7b6ae990eec9c to your computer and use it in GitHub Desktop.
Docker Custom Bridge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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