![docker for mac net host docker for mac net host](https://www.fatalerrors.org/images/blog/43cf9cc273795a583ea5f2259aa63c78.jpg)
(Otherwise, it can’t track the opened ports.) Is there really anything they can do without essentially setting up a bridged NAT in the first place, and just replicating -p? No, there really isn’t.ĭocker was designed with the intent that -p is the way things will work.
![docker for mac net host docker for mac net host](https://www.heise.de/imgs/18/2/5/5/3/1/4/8/Docker_Desktop_Enterprise_graphic_v4-02485d6b10dff763.jpeg)
Is the behavior inconsistent? Yes, it is. So, now, considering that the docker daemon doesn’t even know what port was eventually opened by the container, how would you expect the OSX invoker to even know? How could this work with -net=host? Docker in this case even the docker daemon running on the virtualized Linux machine doesn’t even actually know which port the container opened, because the container has done an “end run” around docker straight to the namespaced kernel. The invoking agent on the Mac knows exactly which port needs to be redirected and how. It is not docker running on the Linux machine that is instigating this port opening. Yes, a -p works so well, because it’s opening a localport that is actually a redirect to an address that is NATed behind the docker bridged networking. I also tried this with pinata set network nat and pinata set network hostnet– neither works. The service doesn’t need to be python3- any native app that binds to localhost will work. 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 $:8000 done'Ĭurl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refusedĬurl: (7) Failed to connect to 192.168.65.2 port 8000: Connection refusedĬurl: (7) Failed to connect to 172.19.0.1 port 8000: Connection refusedĬurl: (7) Failed to connect to 172.18.0.1 port 8000: Connection refusedĬurl: (7) Failed to connect to 172.17.0.1 port 8000: Connection refused On OSX, the output is simply curl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refused $ docker run -it -rm -net=host buildpack-deps:curl curl localhost:8000.
![docker for mac net host docker for mac net host](https://devopssec.fr/images/articles/docker/networks/macvlan_network_docker.jpg)
Should connect to local ports/services Actual behavior