WSL icon indicating copy to clipboard operation
WSL copied to clipboard

LAN redirect issue when Docker installed

Open demfabris opened this issue 6 years ago • 2 comments

Win version 10.0.19041.208 WSL2 running Ubuntu 18.04 LTS

I'm trying to access my laptop's WSL2 instance through other devices in LAN. I used to do this just fine when Docker desktop (with WSL2 integration) wasn't installed. Now i can only access Docker containers through LAN.

Let me explain:

If i set a python Flask server on port 5000 inside WSL2, i can access it on the laptop itself via "localhost:5000" but i cannot access it through any device on my LAN

But, if i set a Flask server inside a Docker container exposing port 5000 i can access it perfectly with all LAN devices.

Here is my windows hosts file (located at %SYSTEMROOT%\System32\drivers\etc\hosts) :

# Added by Docker Desktop
192.168.1.77 hosts.docker.internal
192.168.1.77 gateway.docker.internal
127.0.0.1 kubernetes.docker.internal

I tried adding 127.0.0.1 localhost , 192.168.1.77 localhost. Nothing works

Here's my /etc/resolv.conf:

# This file was automatically generated by WSL. To stop automoatic generation of this file,add the folowing entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.29.48.1

Note: my /etc/wsl.conf is empty

  • What's wrong / what should be happening instead: I should be able to access web services inside WSL2 directly, not just inside docker containers

demfabris avatar May 05 '20 02:05 demfabris

Maybe these two solutions can help you:

  1. https://github.com/shayne/wsl2-hacks
  2. issue#4150

simonmatt avatar May 28 '20 14:05 simonmatt

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!