13

Is there a way to use network mode "host" in the docker container run inside wsl2 using docker desktop?

I tried to deploy a docker container inside wsl2 with network mode "host" but I could not access this port inside windows.

I knew that this was a limitation in docker desktop, but is it still the case with wsl2? And is there any workaround to enable this feature?

I'm using windows 10 pro with build 2004 and ubuntu 20 LTS inside wls2

user8912375
  • 412
  • 1
  • 4
  • 12
  • the problem is not from docker but WSL2, you might want to check out https://stackoverflow.com/questions/61002681/connecting-to-wsl2-server-via-local-network – Do Trung Duc Mar 19 '21 at 03:19
  • I tried to send a request `curl http://:2225/docs` from within the wsl2 from another terminal using the IP address of the `eh0` of the wsl2 but with the same result I did not have any response when using `--network host` – user8912375 Mar 19 '21 at 07:02
  • It should just work when connecting from the same WSL2 guest. I would check if WSL2 distro firewall is enabled first. It should also work from Windows either directly or using port forwarding, but there is a lot of reports that Windows forgets forwarded ports, so it may need Windows reboot from time to time. – Konstantin Pelepelin Aug 16 '21 at 14:02
  • @user8912375 did you ever found a solution? I'm getting the same issue – Wildan Maulana Syahidillah Mar 20 '23 at 02:16
  • 1
    No, it's not supported on windows check: https://github.com/docker/for-win/issues/6736 – user8912375 Mar 21 '23 at 09:52

0 Answers0