Reputation: 81
My current setup is my laptop and desktop, they're connected in the same network. I do webdev so i code in my laptop and see the results in my desktop's browser. After installing docker i can no longer access my laptop's web servers that are being runned inside WSL2 directly, ONLY if they're running inside a Docker container.
This issue wasn't present in WSL1, which is:
If you install docker desktop on your windows machine and enable the new WSL2 integration it will mess your windows 'hosts' file (found at %SYSTEMROOT%\System32\drivers\etc\hosts
)
Docker automatically adds the following:
# Added by Docker Desktop
192.168.1.77 host.docker.internal
192.168.1.77 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
Note that 192.168.1.77 is my laptop static IP which i set in my router
My guess is that these inputs are redirecting my desktop's requests to docker, completely breaking directly access. This is not ideal because i have to build a container for coding a simple react app which leads to alot of useless complexity
ps: I have tried the following entries in hosts file, no success:
192.168.1.77 localhost
also:
172.22.3.92 ubuntu.wsl # managed by wsl2-host (service that creates a hostname for WSL2 ip)
192.168.1.77 ubuntu.wsl
The only workaround is to disable docker and clean hosts file, which isn't really what it suposed to be.
Upvotes: 2
Views: 3032
Reputation: 11
Add this to ~/.wslconfig (win) or /etc/wsl.conf (wsl)
[network]
generateHosts = false
Upvotes: 1