I am working on a project hosted on Docker for Windows using the following configuration:
Host (PC1) Physical IP: 145.118.70.40 on LAN
Host Virtual IP: 10.0.75.1 on DockerNAT
I got the following issue:
A container X (docker run --name X -it --net=host webserver 8080) is able to access the host using the domain name host.docker.internal. If X pings this domain name, it gets the reply from 192.168.65.2. However, in the host, there is no such network! The host cannot even ping X using any of this IP range. X is accessible from the host using DockerNAT network and particularly by IP: 10.0.75.2. It seems there is a bridge or NAT rule that maps 192.168.65.0 to 10.0.75.0. Using this bridge, X can access the host (via 192.168.65.2) and host can access X (via 10.0.75.2). So far no issue. The issue appears when we try to access X from another physical machine (PC2) whose IP= 145.118.70.41 on the host’s LAN. A link such as http://145.118.70.40:8080 is supposed to work on PC2, but it does not. If there is another container Y (docker run -it -p 7000:8080 webserver 8080) running on the same host (PC1) along with X (notice that there is no –net=host option used for Y), Y is accessible from PC2 using http://145.118.70.40:7000. My question is: How to make X also accessible from PC2 using the host’s IP address (just like Y) while keeping the –net=host option?
Thank you.