Home > Blockchain >  container not accessible when using --network host
container not accessible when using --network host

Time:11-22

I am writing a simple nodejs container to forward requests on localhost to a port, the container exposes port 4433

docker build . -t myproxy

when i run the container by publishing ports like

docker run --rm -p 4433:4433 myproxy 

I am able to access my server through http://localhost:4433 as expected but if i try to run the container with --network host i.e

docker run --rm --net host myproxy 

I cannot access the container and get site cannot be reached error. why is container not binding to my host network? if i provide both options i.e.

docker run --rm --net host -p 4433:4433 myproxy 

then i do get warning on console that WARNING: Published ports are discarded when using host network mode which means it does recognize that i am trying to use host network.

OS: MAC

CodePudding user response:

From the Docker docs:

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

  • Related