-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL2 can't reach a docker container's ports mapped to 127.0.0.1 #13182
Comments
I got the same issue. Diagnostic ID: 847C0482-3D8D-4CB9-9156-3B73F11239F3/20230122202353 |
Same. |
I was having the same problem, Reinstalling Docker Desktop (along with removing settings and wsl images) fixed the issue. |
lol, thanks, but not gonna do that (again). |
@rahimalizada can you exactly explain what you did to fix the issue? |
|
@rahimalizada I did it the same way (again) but still got the same errors. |
Yeah, this completely bricked my workflow yesterday. Purging Docker Desktop from my system (e.g. following these steps, and a few others), then rolling back to both |
Just check wsl version
If you see like this 1.1.0.0 try downgrade microsoft/WSL#9508 (comment) |
@shadowmaster63 thanks for the recommendation. Can confirm that downgrading WSL to |
This one should be closed @fabis94 as it's the WSL2 pre-release problem. |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. /lifecycle locked |
Actual behavior
For some reason docker containers started with port mappings that map to 127.0.0.1 specifically, e.g.
-p 127.0.0.1:8020:8020
don't work inside the WSL2 (Ubuntu) environment. I've got a basic web server container started this way and any attempts tocurl http://127.0.0.1:8020
from inside the WSL2 environment (not even from Windows!) fail with a "Connection refused".It's as if the Docker container is blocking the connection because it thinks the connection that is coming from 127.0.0.1 actually isn't coming from 127.0.0.1, because if I just use a port mapping like
-p 8020:8020
which maps the ports to0.0.0.0
instead of127.0.0.1
then it works and the connection to the web server isn't refused anymore.I tried debugging this by making my web server respond by emitting the incoming request IP into the body and saw something strange. I ran the web server with
-p 8020:8020
to make sure I can connect to it, did acurl http://127.0.0.1:8020
from inside WSL2 (not Windows!) and the remote address was outputted to be: 172.17.0.1.Could that be the issue? The remote address should be 127.0.0.1, but it comes in as 172.17.0.1 so Docker doesn't allow connections from WSL2 if the ports are explicitly only mapped to 127.0.0.1
Expected behavior
WSL2 should be able to connect to any containers with port mappings that explicitly use
127.0.0.1
as the hostname instead of the very permissive0.0.0.0
.Information
Output of
& "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check
Docker version
Client: Docker Engine - Community
Cloud integration: v1.0.29
Version: 20.10.22
API version: 1.41
Go version: go1.18.9
Git commit: 3a2c30b
Built: Thu Dec 15 22:28:22 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Desktop
Engine:
Version: 20.10.22
API version: 1.41 (minimum version 1.12)
Go version: go1.18.9
Git commit: 42c8b31
Built: Thu Dec 15 22:26:14 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.14
GitCommit: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Reproduction
I don't think this can be reproduced because things worked fine yesterday and now they suddenly don't work. There were no updates to my system or anything so I have no idea what could've changed.
I would still really appreciate it if someone could offer some extra debugging/troubleshooting steps for me to try.
The text was updated successfully, but these errors were encountered: