--net=host does not work

I wanted to slightly rephrase the original post to make sure I’m experiencing the same thing. Running Docker for Mac Version 1.12.0-rc3-beta18 (build: 9996) on OS X El Capitan 10.11.5

This works:

docker run --rm -p 80:80 nginx

(curl localhost from my Mac returns the nginx page)

This doesn’t work:

docker run --rm -p 80:80 --net host nginx

(curl localhost shows “Failed to connect to localhost port 80”). However, a second container can connect: docker run --rm --net host alpine nc -vz localhost 80 returns localhost (127.0.0.1:80) open

This blocks how we use Docker for development, since we rely on --net host to expose a bunch of services that we’d otherwise have to refactor to refer by container hostname. Can someone confirm that this isn’t intended? Or is this likely to not be fixed?

Explain networking known limitations, explain “host” seems relevant, but there’s no response there either.

2 Likes