I’m having issues with networking in WSL2 which brings me to wonder a bit about how WSL2 is actually used by Docker Desktop when “Use the WSL2 based engine” is ticked.
When running any WSL2 distro I have no working network access, but when running a supposedly WSL2 backed container it works, see issue on GitHub: https://github.com/microsoft/WSL/issues/5862
Is there any difference in starting code (with a dev container configured repo) from within the WSL2 terminal vs from the Powershell terminal?
How is networking set up in making it possible to access external network from within a container in WSL2 but not from the docker-desktop distro itself?
Starting VSCode with a repository that is configured to be used as with a development container it asks if you want to restart in container, when selecting yes it shows “>< Dev Container …” in the bottom left side.
Opening the docker desktop UI shows a container running: “vsc-vscode-remote-try-python…”
Using the built in terminal to check for network access is successful, able to ping 220.127.116.11 for example.
Looking at the documentation for Docker Desktop with WSL2 says you should start code from within the WSL2 distro terminal. All according to: https://docs.docker.com/docker-for-windows/wsl/#develop-with-docker-and-wsl-2
Once VSCode is up the bottom left indicates remote WSL: “>< WSL: Ubuntu 20.04”. Checking network access from the built in terminal by again pinging 18.104.22.168 fails.
Since I am opening the same folder as in the example above (but from the WSL2 distro terminal this time) I get the question if I want to reload in container. Doing this changes the connection info in the bottom left to “>< Dev Container …” once again. And if I take a look at the Docker Desktop UI I can see a running container again, same name as when starting it from outside WSL2
Once again testing external network access by pinging 22.214.171.124 is successful.
Attaching to the running WSL2 instance of “docker-desktop”
NAME STATE VERSION * docker-desktop Running 2
Trying to ping 126.96.36.199 fails, just as for any other WSL2 distro installed.
What makes the containers running within the docker-desktop WSL2 distro able to connect to external network but not the docker-desktop WSL2 distro itself? (I can see a lot of vpnkit* processes running)