So, I would like to run a service inside container which wil be accessible from outside (imagine like httpd). Everything works fine, but the IP of the “visitor” will always be 172.17.42.1. I tried bridged and host mode and it’s the same.
I searched everywhere, but I could not find a single article about this issue …
My question is, what do I have to do, so the service inside container sees the real IP not the host IP?
Thanks
PS: Docker is running on a server that is in the same network as my PC, but different device (like 192.168.1.20 and 192.168.1.30). The issue is also no different, if I access container from outside (via port forwarding).
without much knowledge about it I think the default way is to assume the hosts IP address plus a port number that can be assigned randomly or fixed, so you reach your container’s service under xxx.xxx.xxx.x:yy
For example I run Apache in container. When I access it for example with 192.168.1.60:8080 (IP of docker host in my network), the container sees me as 172.17.42.1, when it should display 192.168.1.70 (my PC) or my external IP, if I access it externally (eg. 175.68.25.69).
Second example. I run SSH inside container and I run command “who” from the client. Instead of getting my real IP, I get 172.17.42.1.
I tried bridge and host most and the thing is the same.
Okay I found out, if I use --net=host then I get real visitor IPs. However, I would prefer using bridge mode, so I do not “contaminate” host with all ports that I don’t even need to be exposed outside of the container.