Skip to content

Instantly share code, notes, and snippets.

@mavenugo
Created October 9, 2016 03:03
Show Gist options
  • Save mavenugo/ce1787c05de504ed4f5d2d1cec86eca2 to your computer and use it in GitHub Desktop.
Save mavenugo/ce1787c05de504ed4f5d2d1cec86eca2 to your computer and use it in GitHub Desktop.
madhu@Madhus-MBP ~ $ docker network create --subnet=40.1.1.0/24 my-user-net
68f40c6cd46aae2fd5388b03020e75741ebba6eeca04251068a2b9d509df2e9f
madhu@Madhus-MBP ~ $ docker run --name=my-svc1 --ip=40.1.1.2 --net=my-user-net -itd busybox sh
072b141a23caf54af5e6091a8eda847787e61eb209d207246d1c7c7bebf4096c
madhu@Madhus-MBP ~ $ docker run --name=my-svc2 --ip=40.1.1.3 --link=my-svc1:mysvc --net=my-user-net -itd busybox sh
84093ed474d985091698db550d9b503c8ac65c7742c7056951e0c21deba3c66c
madhu@Madhus-MBP ~ $ docker exec -it my-svc2 sh
/ # ping mysvc
PING mysvc (40.1.1.2): 56 data bytes
64 bytes from 40.1.1.2: seq=0 ttl=64 time=0.114 ms
64 bytes from 40.1.1.2: seq=1 ttl=64 time=0.093 ms
64 bytes from 40.1.1.2: seq=2 ttl=64 time=0.094 ms
^C
--- mysvc ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.093/0.100/0.114 ms
/ # madhu@Madhus-MBP ~ $
madhu@Madhus-MBP ~ $ docker version
Client:
Version: 1.12.2-rc1
API version: 1.24
Go version: go1.6.3
Git commit: 45bed2c
Built: Tue Sep 27 23:38:15 2016
OS/Arch: darwin/amd64
Experimental: true
Server:
Version: 1.12.2-rc1
API version: 1.24
Go version: go1.6.3
Git commit: 45bed2c
Built: Tue Sep 27 23:38:15 2016
OS/Arch: linux/amd64
Experimental: true
madhu@Madhus-MBP ~ $ docker run --name=my-svc5 -p 9090:9090 --ip=40.1.1.5 --link my-svc1:mysvc --net=my-user-net -itd busybox sh
fdd4d25ce45c2f4a004e761a8bf3b57487b5af5a6cd07377823572a05a3e4954
madhu@Madhus-MBP ~ $ docker exec -it my-svc5 sh
/ # ping mysvc
PING mysvc (40.1.1.2): 56 data bytes
64 bytes from 40.1.1.2: seq=0 ttl=64 time=0.221 ms
64 bytes from 40.1.1.2: seq=1 ttl=64 time=0.087 ms
64 bytes from 40.1.1.2: seq=2 ttl=64 time=0.092 ms
^C
--- mysvc ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.087/0.133/0.221 ms
/ # nc -l -p 9090
hi
madhu@Madhus-MBP ~ $ nc localhost 9090
hi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment