Created
December 3, 2017 15:55
-
-
Save ipolyzos/10d028b3d759bc3073c6ba2b8840e272 to your computer and use it in GitHub Desktop.
test Docker container type network between two containers
This file contains 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
# 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