-
I'm running WSL2 and docker-for-win. I have scoured the resources that I could find, lots of which refer to WSL -> Windows or docker containers -> Windows etc, but not often container -> WSL itself. My personal reproduction right now would be:
Any reading or pointers that I may have overlooked, or misread etc would be greatly appreciated. Perhaps this question would be better aimed toward docker-for-win instead of wsl, but I'v got to start somewhere! To make this issue even more searchable on the web I'll add that All of this was happening while trying to use xdebug for php in a docker container, connecting back to VSCode in remote mode on WSL2. People that are having this issue may just be trying to connect to the wrong IP / domain, and reading https://addshore.com/2021/02/vscode-php-xdebug-from-localhost-wsl2-and-docker-containers/ might help there. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
After trying a variety of debugging etc I ended up uninstalling and reinstalling docker, and everything seems to start working just fine again. The issue was caused by subnet differences between WSL and docker. By default, as far as I can tell WSL & Docker so something special together so that containers end up with an IP on the same subnet as WSL. The added confusion comes from the default docker subnet, and also seemingly configured docker subnet in the UI To make this issue even more searchable on the web I'll add that All of this was happening while trying to use xdebug for php in a docker container, connecting back to VSCode in remote mode on WSL2. People that are having this issue may just be trying to connect to the wrong IP / domain, and reading https://addshore.com/2021/02/vscode-php-xdebug-from-localhost-wsl2-and-docker-containers/ might help there. |
Beta Was this translation helpful? Give feedback.
-
Ugh. I just spent the better part of three days pulling my hair out trying to figure out why Xdebug wouldn't work anymore in my WSL2/Lando/Docker/PHP/VSCode environment. After much frustration I eventually I traced it down to an inability of my Docker container to access the WSL2 host IP where VS Code is running. I could ping other IPs from within Docker, but I couldn't ping my WSL2 IP... I read a bunch of posts online about others with similar issues and tried everything from changing VSCode/Xdebug settings, disabling firewalls, and various internet/network troubleshooting steps, but nothing seemed to fix it or suggest any reason why my Docker container couldn't access my WSL2 host IP. Finally, I found this post and in desperation uninstalled Docker and reinstalled it as suggested and voilà---Xdebug magically works again! It's frustrating that we still don't know why this sometimes happens to WSL2/Docker, but at least I know a relatively quick fix now for when it does happen again next time. |
Beta Was this translation helpful? Give feedback.
After trying a variety of debugging etc I ended up uninstalling and reinstalling docker, and everything seems to start working just fine again.
The issue was caused by subnet differences between WSL and docker.
By default, as far as I can tell WSL & Docker so something special together so that containers end up with an IP on the same subnet as WSL.
For some reason my setup was not doing this.
After reinstalling my containers end up with a bridge network again with 172. IPs (same as WSL). Prior to this the containers were getting 192. IPs.
The added confusion comes from the default docker subnet, and also seemingly configured docker subnet in the UI
To make this issue even more searchabl…