photon
photon copied to clipboard
docker container in host mode is not reachable
Describe the bug
docker container in host mode is not reachable. If i deploy a container in bridge mode, its working fine. But if I deploy it in host mode --net=host i cannot get it work.
Reproduction steps
1. tried to deploy multiple containers with --net=host option.
2. neither could be reached from 4.0 rev1 or rev2
3. Any idea?
...
Expected behavior
Any internal ports of the container should be work from outside the os.
Additional context
No response
~Have you tried to run docker and specifying an ip link ? eg. sudo docker run -it --cap-add=NET_ADMIN --net=host <container> ip link add interlink0 type dummy~
sorry, does not work.
Can you please describe the issue in more detail? --net=host means that the container shares the network interface with the host, so does not get its own IP address. It's not possible to publish a port. See https://docs.docker.com/network/host/ .
Is this something that works with another OS than Photon?
Same issue here.
Fresh installed Photon OS 5.0 GA still has same problem, while ubuntu server works fine.
I will post a way to reproduce later xD
docker run --network host --name nginx nginx
I tried to access the port 80 and no any respond, but weirdly I can assess the page through Photon OS itself by curl both 127.0.0.1 or Photon OS ip. I also tried in ubuntu server and works as expected.
Photon OS version is 5.0 GA, fresh install. It is running in ESXi 6.7
Try using docker run --privileged ...
Try using
docker run --privileged ...
docker run --network host --privileged --name nginx nginx
problem still
See https://github.com/vmware/photon/issues/1506#issuecomment-1913389824 for some more details, but you must add a rule in iptables to permit the traffic to the host (and thus the docker host network).