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

WSL2: Docker doesn't work with default bridged network #4133

Closed
KSiig opened this issue Jun 14, 2019 · 7 comments
Closed

WSL2: Docker doesn't work with default bridged network #4133

KSiig opened this issue Jun 14, 2019 · 7 comments
Labels
wsl2 Issue/feature applies to WSL 2

Comments

@KSiig
Copy link

KSiig commented Jun 14, 2019

Please fill out the below information:

  • Your Windows build number: (Type ver at a Windows Command Prompt)

Microsoft Windows [Version 10.0.18917.1000]

  • What you're doing and what's happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screen shots if that helps demonstrate the problem.)

I'm trying to run a simple Nginx container. I first tried with the following command:
docker run -d -p 80:80 nginx
curl localhost

What happens is that the curl ends up timing out. I can then add the container to the host network:
docker run -d -p 80:80 --network host nginx
And then things are working exactly as they should.

  • Troubleshooting Steps

I'm running Docker version 18.09.6, build 481bc77, both on WSL 2, and on my bare metal Ubuntu 18.04 LTS server. When I run it on my bare metal server, everything works just as expected.
That's the reason why I'm posting this as an issue here, and not on Docker.

@moigagoo
Copy link

Having the same issue. It blocks building of any images that require package installation, so it's pretty serious.

@craigloewen-msft craigloewen-msft added the wsl2 Issue/feature applies to WSL 2 label Jun 14, 2019
@patpilus
Copy link

I've got the same issue with timeout, except it does not even work with --network host

docker run --network host hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.141.81:53: read udp 192.168.141.92:49395->192.168.141.81:53: i/o timeout. See 'docker run --help'.

@StefanScherer
Copy link

@KSiig how have you intalled docker in wsl2? Are you running curl also in wsl2? Are you running Docker Desktop as well? I cannot reproduce the problem. I installed dockerd with the get.docker.com script, started dockerd and started the nginx container. Running curl inside wsl2 works for me regardless of the --network option. Only thing is when you want to run curl.exe from eg. a powershell terminal you have to use the IP address of the wsl2 vm. Run eg. ip addr show dev eth0 and grab the IP address and use this instead of localhost.

We at Docker are working to improve the experience in wsl2 and we'll give an overview of that in a blog post very soon.

@patpilus it seems you have a different network issue, maybe running in a corporate network? DNS lookup for the Docker Hub registry doesn't seem to work.

@moigagoo
Copy link

@StefanScherer Here's what I have done so far:

  1. Installed Windows 10 18917.
  2. Uninstalled Docker Desktop.
  3. Uninstalled Ubuntu, reinstalled from the Store, converted to wsl2.
  4. Installed Docker inside Ubuntu via the official guide. I.e. added the repo and installed docker and docker-compose from there.

At this point, I was trying to run services with docker-compose. One service has a Dockerfile with apt-get install in it. The image for this service failed to build because archive.ubuntu.com was unreachable from inside the container. First, I thought it was a DNS issue and tried adding DNS servers to daemon.json. The values were successfully passed into the container but no host could be reached nonetheless.

Running curl inside wsl2 works for me regardless of the --network option

curl inside wsl2 has nothing to do with Docker. It works for me as well.

Only thing is when you want to run curl.exe from eg. a powershell terminal you have to use the IP address of the wsl2 vm.

Again, this is a whole different case.

We at Docker are working to improve the experience in wsl2 and we'll give an overview of that in a blog post very soon.

You are doing fantastic job, thank you! The only issue I have with running Docker inside WSL2 for now is this one we're discussing, and I can work around that by building my images manually with --network=host. This is inconvenient but usable. Other than that, it works like charm.

I used to use Docker Desktop under Powershell, and it was awesome too. I'd like to switch to WSL2-based Docker just for the sake of lower memory usage and shell speed (pwsh is cool but slow).

@moigagoo
Copy link

@patpilus This is an unrelated issue, it seems like Docker registry is just unreachable from your machine. To make it clear: it's not the Internet being unreachable from inside a running container, it's one particular host being unreachable from the host machine.

@KSiig
Copy link
Author

KSiig commented Jun 15, 2019

@StefanScherer I initially installed Docker by following this tutorial on DigitalOcean: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04

However I had nothing important on WSL, so I deleted my Ubuntu distro and reinstalled it. Then I tried installing Docker from https://get.docker.com, and now it works. Also to answer your question: Yes I was running curl from within WSL.

Although I still think it's weird that it didn't work at first, I think we can classify this as fixed. Apparently you just need to install using get.docker.com (makes sense too).

@rafasimionato
Copy link

rafasimionato commented Dec 22, 2022

I got same problem here. I just uninstalled docker using official procedure and then installed Docker using the helper script from https://get.docker.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wsl2 Issue/feature applies to WSL 2
Projects
None yet
Development

No branches or pull requests

6 participants