Docker Community Forums

Share and learn in the Docker community.

Accessing a container from the second container using the HOST ip

docker

(Rontal) #1

I have two containers that each one is exposing a port.
I want to be able to access the other container using the HOST ip and not the internal ip of the container.
If I access on container using the host ip and port from outside the HOST it works, but accessing the container from the second container using the HOST ip I get host unreachable.


(David Maze) #2

Like:

ifconfig  # prints, say, 192.168.12.34
docker run -d -p 8888:8888 server
docker run client curl http://192.168.12.34:8888/

That should work; what’s going wrong?


(Rontal) #3

Happy that you understand exactly what we want.
Yes, this is exactly what is not working.

Here is some details:
host> docker ps # … 0.0.0.0:40004->22/tcp
host> ifconfig eno16777984 # prints 192.168.2.190
host> telnet 192.168.2.190 40004 # Success
container> telnet 192.168.2.190 40004 # telnet: connect to address 192.168.2.190: No route to host

We try 3 docker host but without success,