How do I reach a ddev site from LAN with docker-ce in an WSL2 enviroment?

682 views Asked by At

When configuring ddev with a project TLD it becomes unreachable when replacing "docker desktop" with "docker-ce".

project_tld: testing

How can I reach the project again from my local machine and from our company LAN?

1

There are 1 answers

0
F.Leudts On BEST ANSWER

The reason for the website becoming unreachable is that WSL2 only binds ports to the localhost and not to every interface.
Docker desktop itself binds to every interface and forwards everything to WSL2 that is why it worked. For docker-ce a manual solution is required.
The problem is documented in the wsl documentation and a solution is described.
A script for discovering and setting the port forwarding automatically is found in an older WSL2 issue on github.

With the localhostForwarding option set (documentation) for WSL2 the following commands work too:

netsh interface portproxy add v4tov4 listenport=80 connectport=80 connectaddress=127.0.0.1
netsh interface portproxy add v4tov4 listenport=443 connectport=443 connectaddress=127.0.0.1

In some future version Microsoft may bring the bridged networking option back for WSL2 see issue discussion.

Edit: After moving from Docker Desktop to docker-ce I have discovered that my solution doesn't work as it prevents wsl from listening to the 127.0.0.1:80/443 after a restart. The powershell solution in the fourth link works as it directly connects to the wsl ip adress.