Docker Community Forums

Share and learn in the Docker community.

Oddity whilst connecting from one container to another via host IP

(Mrmattyboy) #1


I’ve got some containers that run on different hosts in a swarm… as part of their startup, they determine what their public IPs are. To do this, another container runs a service that returns the IP address of the request. The port of this container is publihed on the host and accessible from the internet.

However, even though the containers are hitting the public IP of the underlying host, it’s still returning with the internal container IP!

If I access the IP from another location, I get the correct public IP that I’m accessing it from.

The only thing that I can think of it it’s something to do the iptables rules that docker sets up by default, but not sure.
Has anyone else observed this and/or got around it?

OS: Ubuntu 18.04.1 LTS
Docker: Docker version 18.09.0, build 4d60db4