photon icon indicating copy to clipboard operation
photon copied to clipboard

docker container in host mode is not reachable

Open atilllla2 opened this issue 3 years ago • 7 comments

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

atilllla2 avatar Apr 20 '22 08:04 atilllla2

~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.

dcasota avatar May 24 '22 07:05 dcasota

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?

oliverkurth avatar Jul 11 '22 19:07 oliverkurth

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

itsdapi avatar May 04 '23 02:05 itsdapi

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

itsdapi avatar May 04 '23 04:05 itsdapi

Try using docker run --privileged ...

sshedi avatar May 04 '23 06:05 sshedi

Try using docker run --privileged ...

docker run --network host --privileged --name nginx nginx

problem still

itsdapi avatar May 05 '23 07:05 itsdapi

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).

ghandye avatar Jan 28 '24 00:01 ghandye