How to use docker network
Tags:
How-to
If you want to connect two containers in the same docker network.
Just do the 3 following steps:
- Create network
docker network create test-network
- Connect first container
docker run --name c1--network test-network nginx:latest
- Connect second container
docker run --name c2 --network test-network nginx:latest
Test
Use exec to connect to the container.
docker exec -it c2 /bin/bash
(Should be provided to use curl or ping)
Curl cmd:
curl http://c2
Ping cmd:
ping c2
That is it.
Written on November 4, 2021 at 21:10
Last but not least
If the post is updated, the creation date, will be pushed. So it might happend, you see an existing page back on frontpage. I think, this approach is valid, so wrong information or gained information is covered. But if I am going to write a new part of topic, I might include an updated link to the new post.
Home