Docker Community Forums

Share and learn in the Docker community.

Docker's container with --net=host is not reachable from the network

(Mkaiiali) #1

I am working on a project hosted on Docker for Windows using the following configuration:
Host (PC1) Physical IP: on LAN
Host Virtual IP: 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 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: It seems there is a bridge or NAT rule that maps to Using this bridge, X can access the host (via and host can access X (via So far no issue. The issue appears when we try to access X from another physical machine (PC2) whose IP= on the host’s LAN. A link such as 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 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.

(Jjfraney) #2

I know something about Dockers network architecture, but not much about how it’s implemented inside docke for Windows.

Docker for Windows is running a Linux vm…two distinct hosts from networking perspective. The ‘host’ network in the Linux vm does not extend to the Windows host. My guess.

My guess is the docker for Windows environment links the default docker bridge network of the linux vm to the host’s external network. Magic, somehow. This explains why port binding in container Y can work.

I don’t expect using host network in a linux vm in docker for Windows would work the way you expect. Host network works on a Linux host, but not as configure to run for docker for Windows.

I admit this is a guess, an informed guess, and requires confirmation by a bit more research or by someone with more knowledge than I.

(Mkaiiali) #3

Thank you for your reply.
I got the support answer. As you said, (–net=host) is not fully supported by Docker for Windows.