Expected behavior
docker run --net=host ...
should connect to local ports/services
Actual behavior
It doesn’t.
Information
OS X: version 10.11.5 (build: 15F34)
Docker.app: version v1.11.1-beta13.1
Running diagnostic tests:
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Steps to reproduce the behavior
$ python3 -m http.server --bind localhost
$ curl localhost:8000
$ docker run -it --rm --net=host buildpack-deps:curl curl localhost:8000
Run steps 1 & 2 locally outside docker.
For step 3, this works on Linux.
On OSX, the output is simply
curl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refused
I also tried every address known to the container:
$ docker run -it --rm --net=host buildpack-deps:curl sh -c 'for ip in $(ip addr | grep "inet " | cut -d " " -f 6 | cut -d "/" -f 1); do curl ${ip}:8000; done'
curl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refused
curl: (7) Failed to connect to 192.168.65.2 port 8000: Connection refused
curl: (7) Failed to connect to 172.19.0.1 port 8000: Connection refused
curl: (7) Failed to connect to 172.18.0.1 port 8000: Connection refused
curl: (7) Failed to connect to 172.17.0.1 port 8000: Connection refused
The service doesn’t need to be python3-- any native app that binds to localhost will work.
I also tried this with pinata set network nat
and pinata set network hostnet
– neither works.