Line 6: | Line 6: | ||
</code> | </code> | ||
==== Add | ==== See the network ==== | ||
<code> | |||
docker network ls | |||
</code> <br> | |||
==== Add a container to the network ==== | |||
<code> | <code> | ||
docker run -d --network=phenixnet --name phenixapp -hostname phenixapp -p 8080 nginx | docker run -d --network=phenixnet --name phenixapp -hostname phenixapp -p 8080 nginx | ||
</code> <br> | </code> <br> | ||
==== | ==== Ping the container from another one ==== | ||
This will launch a shell on a busybox container, you can ping, curl etc.<br> | This will launch a shell on a busybox container, you can ping, curl etc.<br> | ||
<code> | <code> | ||
Line 29: | Line 34: | ||
<code> | <code> | ||
docker network rm | docker network rm | ||
</code> <br> | </code> <br> |
Revision as of 22:39, 24 April 2020
Docker Networking
Creating the overlay network
docker network create --driver bridge phenixnet
See the network
docker network ls
Add a container to the network
docker run -d --network=phenixnet --name phenixapp -hostname phenixapp -p 8080 nginx
Ping the container from another one
This will launch a shell on a busybox container, you can ping, curl etc.
docker run -it --rm --network=phenixnet --name phenixapp -hostname phenixclient yauritux/busybox-curl /bin/sh
See the network from the client
curl phenixapp
ping phenixapp
Trash the network
docker network rm