rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.93k stars 280 forks source link

Docker network setting "--net=host" does not work with 1.15.x using windows and wsl #7378

Open benzman81 opened 1 month ago

benzman81 commented 1 month ago

Actual Behavior

Starting a docker container in wsl with network setting "--net=host" does not work anymore as host servers are not available in container and container services not in wsl.

Steps to Reproduce

  1. start some server in wsl (i used npm install -g http-server and started it with http-server -p 8686)
  2. Start a docker container with network setting "--net=host"
  3. Try "wget http://localhost:8686" in container.
  4. Result ist Connection refused

The other way around:

  1. Start a docker container with network setting "--net=host"
  2. start some server in container (i used npm install -g http-server and started it with http-server -p 8787)
  3. Try "wget http://localhost:8787" in wsl.
  4. Result ist Connection refused

Result

Result ist Connection refused wheren accessing both servers.

Expected Behavior

Both services are reachable.

Additional Information

Downgrading back to 1.14.2 also did not work until I disabled "Networking Tunnel". Then it starts working again.

Maybe its related to https://github.com/rancher-sandbox/rancher-desktop/issues/7294 as the address 192.168.1.1 is already pingable within my company network even without starting rancher.

For now we seem to be stuck on 1.14.2 with disabled network tunnel.

Rancher Desktop Version

1.15.x

Rancher Desktop K8s Version

1.30.4

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Microsoft Windows 10 Enterprise 10.0.19045 Build 19045

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

Yes, we use Pulse Secure VPN.

Nino-K commented 2 weeks ago

@benzman81 I managed to reproduce this in the version you mentioned, however, I also tested this in our previous versions 1.11.1 (of course not using Network Tunnel), and it still did not work. It looks as though we have never supported the host network driver mode. However, after reading the documents closely, if you use -p to publish your ports, you will probably achieve what you are trying to do on Rancher Desktop. Once you use the published port flag, you can use one of the following domains to access your port on the host from the container.

host.docker.internal

or

host.rancher-desktop.internal

Can I ask you what is your use case? so, I can help you better.

benzman81 commented 2 weeks ago

@Nino-K hi, we use vscode with RancherDesktop, WSL and Devcontainer. Until 1.15.x all ports from WSL have been available in the devcontainer and all servers started in devcontainer were available outside the devcontainer in WSL( my collegues are using 1.13.x to 1.14.x I think, some may use older versions but without devcontainer). Since ports on both side are not fixed as it differs per developer and use case, we used host network for starting the devcontainer. Now v1.15. stops us from upgrading. Hope that helps.

Nino-K commented 2 weeks ago

I think I understand a bit better, can you guys avoid using --net=host argument and use -p (published ports) instead?

benzman81 commented 2 weeks ago

As I stated, since ports are not fixed I do not know how to solve this. It is not defined which server and how many a developer starts in wsl oder in the devcontainer.