Docker Community Forums

Share and learn in the Docker community.

How to access service running in a different container on same host with HOST_IP:Port


(Kespar) #1

Hello

I am running two containers on a single host container_one trying to access service of container_two using HOST_IP:Port, but I am not able to access it.
container_two_ip:port is working, from host2 to host1:port is working.

can anyone help me to figure out what configuration I have to do ?

I tried
docker run --dns={{ docker_bridge_ip }} -e DOCKER_HOST=HOST1_IP

I know I can access it using container_two_IP:port and it working also, but we want to access it via host_ip:port only from same node and different container.


(David Maze) #2

You’ve read through https://docs.docker.com/engine/userguide/networking/ and the things that are linked from there?

Using a container’s private IP address is almost always wrong. From the host, use docker run -p to publish ports out of containers; between containers, the recommended way is to set up a private network and use the other container’s name as a normal DNS name, and the older way is to use the default bridge network and docker run --link.