Skip to content

Instantly share code, notes, and snippets.

@ipolyzos
Created December 3, 2017 15:55
Show Gist options
  • Save ipolyzos/10d028b3d759bc3073c6ba2b8840e272 to your computer and use it in GitHub Desktop.
Save ipolyzos/10d028b3d759bc3073c6ba2b8840e272 to your computer and use it in GitHub Desktop.
test Docker container type network between two containers
# Start a busybox container that just waits
$ docker run -d --name=justwait busybox sleep 3600
# Start another container and connect is to the network on the first container
$ docker run -d --name=sharednettwo --net=container:justwait busybox sleep 3600
# Test that containers use the same IP address as the first container
# i.e. use the same networking namespace to both containers
$ docker exec -ti justwait ifconfig
...
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:02
inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
...
$ docker exec -ti sharednettwo ifconfig
...
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:02
inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment