Skip to content

Instantly share code, notes, and snippets.

@tuxpower
Last active August 22, 2016 13:53
Show Gist options
  • Save tuxpower/8b086db8e0aac6847de1e0b5c983b393 to your computer and use it in GitHub Desktop.
Save tuxpower/8b086db8e0aac6847de1e0b5c983b393 to your computer and use it in GitHub Desktop.
Docker - Manipulating networks, names and aliases
$ docker network create blue
368305ab14a4b276905948806bc31f72df9e28bea6798336abe272f8fd1c0811
$ docker network create green
8b74c5d61262bc22bbcb8a045caba38e05b46116706ea26719e8be1061083336
$ docker run -d --name sky --net blue --net-alias things redis
d7c7b09fafe0823d2f428bce882b850e45fb5ea23b569e65b9d7ea7cb3c4b17f
$ docker run -d --name navy --net blue --net-alias things redis
eeb78a572ca66f208443fb19a2cc1d44a4c761da10727f322942860de87fa713
$ docker run -d --name grass --net green --net-alias things redis
50eae13973aa284e27c5404e7c506e49ab8e9d2b2370cd68153b13ef907a866c
$ docker run -d --name forest --net green --net-alias things redis
da2d5766dea7a91f96566b5ad461f56a5e4dbccf85cbd926ce471e0fc8896242
$ docker run -it --net blue alpine sh
/ # ping navy
PING navy (172.18.0.3): 56 data bytes
64 bytes from 172.18.0.3: seq=0 ttl=255 time=0.158 ms
64 bytes from 172.18.0.3: seq=1 ttl=255 time=0.062 ms
^C
--- navy ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.062/0.110/0.158 ms
/ #
/ # ping sky
PING sky (172.18.0.2): 56 data bytes
64 bytes from 172.18.0.2: seq=0 ttl=255 time=0.101 ms
64 bytes from 172.18.0.2: seq=1 ttl=255 time=0.063 ms
64 bytes from 172.18.0.2: seq=2 ttl=255 time=0.061 ms
^C
--- sky ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.061/0.075/0.101 ms
/ #
/ #
/ # ping forest
ping: bad address 'forest'
/ #
/ #
/ #
$ docker run -it --net green alpine sh
/ #
/ # ping forest
PING forest (172.19.0.3): 56 data bytes
64 bytes from 172.19.0.3: seq=0 ttl=255 time=0.124 ms
64 bytes from 172.19.0.3: seq=1 ttl=255 time=0.063 ms
^C
--- forest ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.063/0.093/0.124 ms
/ #
/ #
/ # ping grass
PING grass (172.19.0.2): 56 data bytes
64 bytes from 172.19.0.2: seq=0 ttl=255 time=0.091 ms
64 bytes from 172.19.0.2: seq=1 ttl=255 time=0.064 ms
^C
--- grass ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.064/0.077/0.091 ms
/ #
/ #
/ # ping sky
ping: bad address 'sky'
/ #
/ #
/ # ping 172.18.0.2
PING 172.18.0.2 (172.18.0.2): 56 data bytes
^C
--- 172.18.0.2 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
/ #
/ #
/ # nslookup things
nslookup: can't resolve '(null)': Name does not resolve
Name: things
Address 1: 172.19.0.2 grass.green
Address 2: 172.19.0.3 forest.green
/ #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment