Skip to content
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

Cannot access port on Windows from Docker container via host-gateway #12023

Closed
1 of 2 tasks
Morthy opened this issue Sep 11, 2024 · 4 comments
Closed
1 of 2 tasks

Cannot access port on Windows from Docker container via host-gateway #12023

Morthy opened this issue Sep 11, 2024 · 4 comments
Labels

Comments

@Morthy
Copy link

Morthy commented Sep 11, 2024

Windows Version

Microsoft Windows [Version 10.0.22631.4037]

WSL Version

2.3.17.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

Linux version 5.15.153.1-microsoft-standard-WSL2

Distro Version

Ubuntu 20.04

Other Software

Docker version 27.2.0, build 3ab4256

Repro Steps

My setup is as follows.

WSL Config:

memory=25GB
networkingMode=mirrored
dnsTunneling=true
[experimental]
hostAddressLoopback=true
  • Running a debugger listening on port 9003 on the Windows host
  • Running docker engine directly on my WSL instance
  • Running docker containers with a bridged network

I expect my docker containers to be able to connect to the debugger running on Windows, but they are not able to connect.

The docker container is configured with an extra_host to post host.docker.internal to the host gateway:

- "host.docker.internal:host-gateway"

From the docker container, I get these results:

# telnet host.docker.internal 9003
Trying 10.253.0.1...
telnet: Unable to connect to remote host: Connection refused

If I try the IP of my Windows host directly, that does seem to work:

# telnet 192.168.178.84 9003
Trying 192.168.178.84...
Connected to 192.168.178.84.
Escape character is '^]'.

However, I would expect the first attempt to also work, so that I can avoid hardcoding my windows IP in my docker setup.

Expected Behavior

Connecting to a Windows host port over the docker host IP or Ubuntu host IP should work

Actual Behavior

Connection is not possible

Diagnostic Logs

The networking logs were recorded while running both the unsuccessful and successful attempts above

WslNetworkingLogs-2024-09-11_18-52-21.zip

Copy link

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
Detected appx version: 2.3.17.0
optional-components.txt not found

@zcobol
Copy link

zcobol commented Sep 12, 2024

When set to True, will allow the Container to connect to the Host, or the Host to connect to the Container, by an IP address that's assigned to the Host

Looks like you're connecting to the IP address that's assigned to the Host just fine!

@Morthy
Copy link
Author

Morthy commented Sep 12, 2024

Yeah, that’s what is allowing the second test to work. I was under the expectation the first option would work too, unless im understanding wrong?

@Morthy
Copy link
Author

Morthy commented Sep 12, 2024

So I'm not entirely sure why, but after a fresh boot today host.docker.internal is now resolving to the IP of my host, and so its working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants