WSL2: Access from Windows to container IPs
Is your feature request related to a problem? Please describe.
As we have a development workflow based on DNS, to achieve this we need the access to containers ips from the dev machies. It is quite straightforward on Linux, on OSX we just need to set a custom route 172.16.0.0/24 to the docker-machine.
How can we achieve this on WSL2 ? Is there something already supported ?
Thanks!
I have a similar setup, and it unfortunatelly does not work out of the box with WSL2 since it's IP address changes every time you restart.
But, it works with Docker running inside WSL2. So, if you can set up your development workflow to use Docker instead it works fine.
I have nginx running with Docker on WSL2 and dnsmasq pointing all *.user.local wildcard-domains to 192.168.1.100 which is assigned to my Windows machine. This allows me to access my services from any device within my LAN.
Please try these solutions that could help you guys:
- https://github.com/microsoft/WSL/issues/4150
- https://github.com/shayne/wsl2-hacks
Thanks @simonmatt but i cannot still find a way there on how to access containers from windows, using their internal ips.
I can do it quite easily on OSX + Virtualbox just by adding a static route to 172.17.0.0 to the virtuabox vm.
I don’t know the internals of hyperV and Windows to understand if this is technically doable.