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.