Anonymous
×
Create a new article
Write your page title here:
We currently have 27 articles on PhenixOps. Type your article name above or click on one of the titles below and start writing!



PhenixOps
27Articles

Docker Networking: Difference between revisions

(Created page with "== Docker Networking == ==== Creating the overlay network ==== <code> docker network create --driver bridge phenixnet </code> ==== Add the App to the network ==== <code> doc...")
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Docker Networking ==
== Docker Networking ==
Containers can discover eachother when launched on the same net<br>
Modes are
* bridged
* host
* none


==== Creating the overlay network ====
==== Creating the overlay network ====
Line 6: Line 13:
</code>
</code>


==== Add the App to the network ====
==== 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>


==== Add another container and ping the App ====
==== 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>
docker run -it --rm --network=phenixnet --name phenixapp -hostname phenixclient yauritux/busybox-curl /bin/sh
docker run -it --rm --network=phenixnet --name phenixapp -hostname phenixclient yauritux/busybox-curl /bin/sh
Line 31: Line 44:
</code> <br>
</code> <br>


==== See the network ====
[[Category:Docker]]
<code>
docker
</code> <br>

Latest revision as of 23:21, 24 April 2020

Docker Networking

Containers can discover eachother when launched on the same net

Modes are

  • bridged
  • host
  • none

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