Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

WSL 2 docker client cannot reach Docker Desktop via tcp://0.0.0.0:2375 #4321

Closed
langlin opened this issue Jul 19, 2019 · 34 comments
Closed

WSL 2 docker client cannot reach Docker Desktop via tcp://0.0.0.0:2375 #4321

langlin opened this issue Jul 19, 2019 · 34 comments

Comments

@langlin
Copy link

langlin commented Jul 19, 2019

  • Your Windows build number: 10.0.18932.1000
  • Ubuntu 18.04
$ lsb_release  -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic
  • For Windows 10 FAST track until 10.0.18912.1000, I can use docker client in WSL 1 with Docker Desktop 18.01 - 18.09 simply through two configurations.
    In Docker Desktop:
    check "Expose daemon on tcp://localhost:2375 without TLS"
    In WSL 1:
    export DOCKER_HOST=tcp://0.0.0.0:2375

After upgraded to the build 18932 and WSL 2, docker client in WSL won't connect to Docker Desktop engine. Sample error.

$ docker image ls
Cannot connect to the Docker daemon at tcp://0.0.0.0:2375. Is the docker daemon running?

Still, the windows cmd side, docker client works as expected.

$ docker image ls
REPOSITORY                                                   TAG                 IMAGE ID            CREATED
        SIZE
dregistry.corp.xxxx.com:5443/de/nukl-bamboo           v1                  13cac1c2e659        2 weeks ago
        3.47GB
dregistry.corp.xxxx.com:5443/de/nukl-bamboo           latest              6378579fd96c        5 weeks ago
        730MB
dregistry.corp.xxxx.com:5443/de/rgp-bamboo            latest              43e7c044a2e3        6 weeks ago
        4.03GB
dregistry.corp.xxxx.com:5443/de/liteon723             latest              b8aa4d6c5888        8 weeks ago
        2.04GB
dregistry.corp.xxxx.com:5443/de/bezeq-dev             latest              0ac9e2c171ff        2 months ago
        2.1GB
ubuntu                                                       xenial              a3551444fc85        2 months ago
        119MB
dregistry.corp.xxxx.com:5443/de/nukl-build            <none>              a59151f7cb8b        2 months ago
        716MB
dregistry.corp.xxxx.com:5443/de/smart-gateway-build   latest              52b2485d5a31        6 months ago
        456MB

@langlin
Copy link
Author

langlin commented Jul 19, 2019

It could be a local networking issue. Here are the ip addresses and the route table.

$ ipconfig

Windows IP Configuration

Ethernet adapter vEthernet (Default Switch):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::b837:aabe:a79a:66a1%35
   IPv4 Address. . . . . . . . . . . : 172.29.160.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

Ethernet adapter vEthernet (DockerNAT):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::98b:ff02:cfe4:4823%6
   IPv4 Address. . . . . . . . . . . : 10.0.75.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : corp.xxxx.com
   Link-local IPv6 Address . . . . . : fe80::851d:67f0:5085:945d%5
   IPv4 Address. . . . . . . . . . . : 172.27.121.180
   Subnet Mask . . . . . . . . . . . : 255.255.255.248
   Default Gateway . . . . . . . . . : 172.27.121.177

Ethernet adapter Npcap Loopback Adapter:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::9df2:af9c:b5a8:d9d5%25
   Autoconfiguration IPv4 Address. . : 169.254.217.213
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

Ethernet adapter vEthernet (nat):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::9507:45cb:fcc5:c8ff%58
   IPv4 Address. . . . . . . . . . . : 192.168.0.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::8431:ce7:e67c:9239%88
   IPv4 Address. . . . . . . . . . . : 172.31.144.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
$ route PRINT
===========================================================================
Interface List
 33...00 0e c6 a9 17 47 ......ASIX AX88179 USB 3.0 to Gigabit Ethernet Adapter
 35...00 15 5d 4b 11 03 ......Hyper-V Virtual Ethernet Adapter
  6...00 15 5d 30 1e 0f ......Hyper-V Virtual Ethernet Adapter #2
  5...18 66 da 29 de 6c ......Intel(R) Ethernet Connection (2) I219-LM
 25...02 00 4c 4f 4f 50 ......Npcap Loopback Adapter
 23...7c dd 90 8a 96 26 ......Microsoft Wi-Fi Direct Virtual Adapter #2
 21...7c dd 90 8a 96 27 ......Microsoft Wi-Fi Direct Virtual Adapter #4
 14...7c dd 90 8a 96 24 ......802.11n USB Wireless LAN Card #4
  1...........................Software Loopback Interface 1
 58...00 15 5d 0d 2a 73 ......Hyper-V Virtual Ethernet Adapter #3
 88...00 15 5d 72 c4 bf ......Hyper-V Virtual Ethernet Adapter #4
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0   172.27.121.177   172.27.121.180     25
        10.0.75.0    255.255.255.0         On-link         10.0.75.1    271
        10.0.75.1  255.255.255.255         On-link         10.0.75.1    271
      10.0.75.255  255.255.255.255         On-link         10.0.75.1    271
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
      169.254.0.0      255.255.0.0         On-link   169.254.217.213    281
  169.254.217.213  255.255.255.255         On-link   169.254.217.213    281
  169.254.255.255  255.255.255.255         On-link   169.254.217.213    281
   172.27.121.176  255.255.255.248         On-link    172.27.121.180    281
   172.27.121.180  255.255.255.255         On-link    172.27.121.180    281
   172.27.121.183  255.255.255.255         On-link    172.27.121.180    281
     172.29.160.0    255.255.240.0         On-link      172.29.160.1    271
     172.29.160.1  255.255.255.255         On-link      172.29.160.1    271
   172.29.175.255  255.255.255.255         On-link      172.29.160.1    271
     172.31.144.0    255.255.240.0         On-link      172.31.144.1   5256
     172.31.144.1  255.255.255.255         On-link      172.31.144.1   5256
   172.31.159.255  255.255.255.255         On-link      172.31.144.1   5256
      192.168.0.0    255.255.240.0         On-link       192.168.0.1   5256
      192.168.0.1  255.255.255.255         On-link       192.168.0.1   5256
   192.168.15.255  255.255.255.255         On-link       192.168.0.1   5256
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link   169.254.217.213    281
        224.0.0.0        240.0.0.0         On-link    172.27.121.180    281
        224.0.0.0        240.0.0.0         On-link         10.0.75.1    271
        224.0.0.0        240.0.0.0         On-link      172.29.160.1    271
        224.0.0.0        240.0.0.0         On-link       192.168.0.1   5256
        224.0.0.0        240.0.0.0         On-link      172.31.144.1   5256
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link   169.254.217.213    281
  255.255.255.255  255.255.255.255         On-link    172.27.121.180    281
  255.255.255.255  255.255.255.255         On-link         10.0.75.1    271
  255.255.255.255  255.255.255.255         On-link      172.29.160.1    271
  255.255.255.255  255.255.255.255         On-link       192.168.0.1   5256
  255.255.255.255  255.255.255.255         On-link      172.31.144.1   5256
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    331 ::1/128                  On-link
 25    281 fe80::/64                On-link
  5    281 fe80::/64                On-link
  6    271 fe80::/64                On-link
 35    271 fe80::/64                On-link
 58   5256 fe80::/64                On-link
 88   5256 fe80::/64                On-link
  6    271 fe80::98b:ff02:cfe4:4823/128
                                    On-link
 88   5256 fe80::8431:ce7:e67c:9239/128
                                    On-link
  5    281 fe80::851d:67f0:5085:945d/128
                                    On-link
 58   5256 fe80::9507:45cb:fcc5:c8ff/128
                                    On-link
 25    281 fe80::9df2:af9c:b5a8:d9d5/128
                                    On-link
 35    271 fe80::b837:aabe:a79a:66a1/128
                                    On-link
  1    331 ff00::/8                 On-link
 25    281 ff00::/8                 On-link
  5    281 ff00::/8                 On-link
  6    271 ff00::/8                 On-link
 35    271 ff00::/8                 On-link
 58   5256 ff00::/8                 On-link
 88   5256 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

@david-dumke
Copy link

You no longer need to use docker for desktop you simply run docker native within WSL 2. Since its now using Hyper-V and has a real kernel. You will need to remove the export DOCKER_HOST from your environment and start the docker daemon using systemctl.

Issue should be closed as a non-issue, it works perfectly in Ubuntu-18.04 I've tested it there myself.

@alexknips
Copy link

You no longer need to use docker for desktop you simply run docker native within WSL 2. Since its now using Hyper-V and has a real kernel. You will need to remove the export DOCKER_HOST from your environment and start the docker daemon using systemctl.

Issue should be closed as a non-issue, it works perfectly in Ubuntu-18.04 I've tested it there myself.

That is partially correct.
If you then run the docker daemon inside WSL2 as a linux native docker, you will need to know how to connect to that Daemon from windows for a variety or reasons (people have DBs running inside docker that they want to connect to from WSL and from windows).

@david-dumke
Copy link

david-dumke commented Jul 19, 2019

You no longer need to use docker for desktop you simply run docker native within WSL 2. Since its now using Hyper-V and has a real kernel. You will need to remove the export DOCKER_HOST from your environment and start the docker daemon using systemctl.
Issue should be closed as a non-issue, it works perfectly in Ubuntu-18.04 I've tested it there myself.

That is partially correct.
If you then run the docker daemon inside WSL2 as a linux native docker, you will need to know how to connect to that Daemon from windows for a variety or reasons (people have DBs running inside docker that they want to connect to from WSL and from windows).

This may be true but I believe the post is talking simply about running a docker container not connecting a database to a docker container running in WSL2.

Edit: Typo :)

@alexknips
Copy link

You no longer need to use docker for desktop you simply run docker native within WSL 2. Since its now using Hyper-V and has a real kernel. You will need to remove the export DOCKER_HOST from your environment and start the docker daemon using systemctl.
Issue should be closed as a non-issue, it works perfectly in Ubuntu-18.04 I've tested it there myself.

That is partially correct.
If you then run the docker daemon inside WSL2 as a linux native docker, you will need to know how to connect to that Daemon from windows for a variety or reasons (people have DBs running inside docker that they want to connect to from WSL and from windows).

This may be true but I believe the post is talking simply about running a docker container not connecting a database to a docker container running in WSL2.

Edit: Typo :)

I was just explaining why some people still might want to run the docker container in Windows for Docker generally.
Running docker in linux directly works generally but might not be what the original author of this issue wants to do. But they should just answer that themselves.

@langlin
Copy link
Author

langlin commented Jul 19, 2019

You no longer need to use docker for desktop you simply run docker native within WSL 2. Since its now using Hyper-V and has a real kernel. You will need to remove the export DOCKER_HOST from your environment and start the docker daemon using systemctl.
Issue should be closed as a non-issue, it works perfectly in Ubuntu-18.04 I've tested it there myself.

That is partially correct.
If you then run the docker daemon inside WSL2 as a linux native docker, you will need to know how to connect to that Daemon from windows for a variety or reasons (people have DBs running inside docker that they want to connect to from WSL and from windows).

This may be true but I believe the post is talking simply about running a docker container not connecting a database to a docker container running in WSL2.
Edit: Typo :)

I was just explaining why some people still might want to run the docker container in Windows for Docker generally.
Running docker in linux directly works generally but might not be what the original author of this issue wants to do. But they should just answer that themselves.

Thanks, Alex and Strike. Indeed, as Alex stated, there are reasons for us to keep using Docker Desktop on Windows. Migrating all containers and volumes from Windows side to native Linux is not a one day job. Docker announced that they would move to WSL2 in future. I guess that there is a day that we will complete the migration. :-)

@fanvinga
Copy link

fanvinga commented Aug 6, 2019

If you then run the docker daemon inside WSL2 as a linux native docker, you will need to know how to connect to that Daemon from windows for a variety or reasons (people have DBs running inside docker that they want to connect to from WSL and from windows).

I am looking for how to access the docker host running in wsl2 from Windows and even remote desktop like macOS/Linux.
Can I directly set the startup parameters in /lib/system/systemd/docker.service as in normal Linux and add -H tcp://0.0.0.0:2736?
Then using some trick to access wsl2 docker host remotely(port forwarding and so on?)

@Biswa96
Copy link

Biswa96 commented Aug 6, 2019

@fanvinga I have tried that with SysVinit procedure. For that, add DOCKER_OPTS="--host tcp://0.0.0.0:2375" line in /etc/default/docker file as root. Then start docker daemon in WSL with sudo service docker start. Now add set DOCKER_HOST=tcp://localhost:2375 in Windows side an run docker client.

For systemd, here are some discussions #994 (comment).

@fanvinga
Copy link

fanvinga commented Aug 6, 2019

@Biswa9 Sincerely thank you for your help, I set up the Windows inbound network firewall by the way, now I can use the docker client on my macOS to link the docker host in Windows WSL.

@alexknips
Copy link

There now is the docker desktop preview that can work together with a docker daemon running in WSL2

@l8nite
Copy link

l8nite commented Sep 10, 2019

Is there a fix for this issue that leaves Docker for Windows running?

@Biswa96
Copy link

Biswa96 commented Sep 10, 2019

Didn't anyone watch this video about Docker Desktop Integration with WSL?

@l8nite
Copy link

l8nite commented Sep 10, 2019 via email

@houstonhaynes
Copy link

Didn't anyone watch this video about Docker Desktop Integration with WSL?

I tried. The accents are extremely difficult to parse out what they're saying. And the host stopping every 45 seconds to dumb down the presentation with quips like "So, magic." don't help AT ALL.

@rickywu
Copy link

rickywu commented Sep 23, 2019

@fanvinga I have tried that with SysVinit procedure. For that, add DOCKER_OPTS="--host tcp://0.0.0.0:2375" line in /etc/default/docker file as root. Then start docker daemon in WSL with sudo service docker start. Now add set DOCKER_HOST=tcp://localhost:2375 in Windows side an run docker client.

For systemd, here are some discussions #994 (comment).

I still got Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
And need start new session to solve this problem

@dean0bambin0
Copy link

Anyone get this working? I have docker running using wsl context and can list my docker images from wsl2 and from windows cmd using 'docker image ls' but when i try view images using eclipse or kitematic from windows it doesn't find any images or containers. I'm trying to connect with localhost:2375. I have checkbox ticked to expose daemon on localhost:2375. I get the feeling kitematic and eclipse are looking for images in default windows context docker.

@jefferai
Copy link

Anyone get this working? I have docker running using wsl context and can list my docker images from wsl2

I can't even get that special sauce working. What address did you use? I've tried the address in resolv.conf and localhost, didn't work.

@InsulinShock
Copy link

InsulinShock commented Dec 24, 2019

I think i have hit the same issue with running dockcross. Try running docker info as sudo. It seems to be the port that requires sudo privileges.

=== try setting as follows ===
sudo groupadd docker

sudo usermod -aG docker $USER

sudo chown root:docker /var/run/docker.sock

@twistezo
Copy link

After a couple of hours I finally solved the error Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running? and other similar problems which prevented to proper cooperation between WSL 2 and Docker Desktop WSL 2 backend.

The most common cause are the remains of old Docker approach under WSL 1. For example by set environment variable DOCKER_HOST=tcp://localhost:2375 under WSL for cooperating with Windows Docker option Expose daemon on tcp://localhost:2375 without TLS. If you used a different approach, it doesn't matter now.
I suspect you have already tried a lot of advices so in my opinion the best you can do is to completely remove Docker from WSL and from Windows and all their residues. Then install latest versions of Windows Docker.

I assume you have already latest version of Windows 10 and WSL 2 with upgraded linux distro from WSL 1 to WSL 2.

How to completely remove Docker from Ubuntu (WSL)?

  1. As official Docker docs says:

    sudo apt-get remove docker docker-engine docker.io containerd runc

    You can add to this list also docker-ce and docker-ce-cli.

  2. Identify all docker packages what you have with dpkg -l | grep -i docker and remove if any still exists.

  3. Remove all residues:

    sudo rm -rf /var/lib/docker /etc/docker /etc/apparmor.d/docker /var/run/docker.sock /usr/local/bin/docker-compose /etc/docker
    
    sudo groupdel docker ~/.docker
    
  4. Be careful with this step. Probably you don't need it. It's for advanced users. Find all docker word occurrences and remove these you are sure of.

    sudo find / -name "*docker*"

  5. You should check all below files content for docker occurrences like ex. environment variable DOCKER_HOST=tcp://localhost:2375 which is residue from WSL 1 and its way to cooperate with Windows Docker by option Expose daemon on tcp://localhost:2375 without TLS.

    You can edit these files with Nano editor nano ~/.bashrc or Visual Studio Code code ~/.bashrc.

    ~/.bashrc
    ~/.bash_aliases
    ~/.bash_profile
    ~/.bash_login
    ~/.profile
    /etc/bash.bashrc
    /etc/profile
    

How to completely remove Docker from Windows?

  1. Firstly uninstall in normal way with Windows Apps & features panel.

  2. Remove all below if exists:

    C:\Program Files\Docker
    C:\ProgramData\Docker
    C:\Users\[USERNAME]\.docker
    C:\Users\[USERNAME]\AppData\Local\Docker
    C:\Users\[USERNAME]\AppData\Roaming\Docker
    

What next?

You should install latest version of Docker Desktop Edge from here and follow steps from official docs.

If everything goes fine you should have output from wsl -l -v like:

  NAME                   STATE           VERSION
* Ubuntu-18.04           Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2

Some tutorials or advices can confuse you because this time you shouldn't install or config anything related with Docker under your WSL linux distro. It is very important. It should works out of the box after a few of simple steps from Docker docs.

Latest working versions (for today):

  • Windows 10 build 19041 from windows insider slow ring
  • WSL 2
  • Docker Desktop WSL 2 backend (v. 2.1.7.0)

TL;DR

  1. Get latest versions of Windows 10 (insider) and convert your WSL 1 distro to WSL
  2. Remove Docker and all its occurrences from WSL distro.
  3. Remove Docker and all its occurences from Windows.
  4. Install latest version Docker for Windows - "Docker Desktop WSL 2 backend".
  5. Follow steps from Docker docs and don't touch anything related to Docker in your WSL distro. It should work out of the box.

@AlexanderAllen
Copy link

@twistezo This is a good comment, #4321 (comment). You should definitely post this on a blog or something.

I have a question for you: Have you tried using Alpine on WSL version 2?

My Ubuntu WSL 2 works just fine with the new in-WSL socket Docker Desktop publishes. But for the love of my life I can't get Alpine to connect to Docker Desktop's socket.

I wonder about other distros such as Debian.

@twistezo
Copy link

twistezo commented Feb 4, 2020

@AlexanderAllen no, I haven't tried Alpine.

@AlexanderAllen
Copy link

For those not running on Ubuntu, @simonferquel over at at Docker for Windows figured out what was my issue. It was not on the WSL end, but on the Docker Desktop end. I needed to install glibc on my Alpine WSL 2 instance. After that Docker Desktop installed the dependencies it needed inside the WSL 2 instance, and with them WSL Alpine was able to make a unix socket connection (not TCP) to Docker Desktop.

The issue is here docker/for-win#5681

@YoungjaeKim
Copy link

YoungjaeKim commented Apr 22, 2020

Thanks @twistezo your solution works.
Note to all that;

  • Don't need to check 'Expose daemon on .. without TLS' (default)
  • Switch on Docker Desktop > Resources > WSL Integration > Ubuntu
  • If ubuntu shell has been opened while doing above steps, exit the shell and reopen it after all installation and setup have finished.
  • you can simply check everything is fine by docker stats command.

@dwthien
Copy link

dwthien commented Apr 28, 2020

as @twistezo said:

  • I used the uninstall software (revouninstaller free) to remove all docker on in windows 10, install again ubuntu 18.08.
    it worked.

@davclark
Copy link

davclark commented May 8, 2020

I think i have hit the same issue with running dockcross. Try running docker info as sudo. It seems to be the port that requires sudo privileges.

Yup - I'm seeing the same thing on WLinux / Pengwin. If I run a Docker command as my regular user, it says it can't connect to port 2375, but with sudo it works.

Interestingly, my regular user is already a member of the docker group, and the docker.sock file is group read-write for the docker group. But something is setting DOCKER_HOST to tcp://0.0.0.0:2375. I have no idea what... there is nothing in my bash startup files that would do this...

So in my case, the solution is similar to what you suggest below, except I need to manually set DOCKER_HOST (which I can make permanent in my .profile or similar). Still not a great first experience for folks running Pengwin!

=== try setting as follows ===
sudo groupadd docker

sudo usermod -aG docker $USER

sudo chown root:docker /var/run/docker.sock

EDIT: There appears to have been a holdover from a previous docker install. I needed to uninstall Docker (via pengwin-setup), and then when I enabled Docker for WSL2 after that, DOCKER_HOST was no longer set.

@simonferquel
Copy link

@davclark actually the DOCKER_HOST env var problem is the only one that matters: our integration actually creates the group and add the default user to this group for you.

I suppose something in Pengwin used to do some magic for making docker desktop work with WSL 1 and thus broke on WSL 2

@simonmatt
Copy link

simonmatt commented May 15, 2020

I did every step by the official guide, then this issue occurs. I tried to remove export DOCKER_HOST=tcp://localhost:2735 from ~/.zshrc of my WSL Ubuntu, and then restarted terminal, after that, it works properly with command docker version on WSL.

If you guys using ~/.bashrc, maybe you try to remove the variable from your ~/.bashrc. Or you can refer this issue .


OS: Windows 10 build 19041
WSL2: Ubuntu 18.04
Docker Desktop: 2.3.0.2(45183)

# WSL Ubuntu
$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:25:46 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
# Windows 10
❯ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@artembatura
Copy link

artembatura commented May 30, 2020

My steps to work WSL 2 with Docker Desktop on Windows

  1. Removed export DOCKER_HOST=tcp://localhost:2375 from ~/.bashrc;
  2. Disabled Expose daemon on tcp://localhost:2375 without TLS in Docker Desktop;
  3. Enabled Use the WSL 2 based engine in Docker Desktop

And then docker info shows normal output instead of Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

@ctataryn
Copy link

My steps to work WSL 2 with Docker Desktop on Windows

1. Removed `export DOCKER_HOST=tcp://localhost:2375` from `~/.bashrc`;

2. Disabled `Expose daemon on tcp://localhost:2375 without TLS` in Docker Desktop;

3. Enabled `Use the WSL 2 based engine` in Docker Desktop

And then docker info shows normal output instead of Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

In this case, you are not communicating to Docker Desktop via the DOCKER_HOST env var. Instead you are choosing to use WSL2 for container/volume storage. If after doing your steps you did a docker ps --all you'll see that you no longer have any containers, they don't port over from your Hyper-V container storage. Essentially you have to start over and rebuild all your containers.

@dayne
Copy link

dayne commented Aug 6, 2020

Noticed this issue when going down a similar path and I want to concur with @ctataryn solution.

The most recent version of WSL2 and Docker Desktop 2.3.0.2 or greater with the WSL2 featured enabled means you can avoid this problematic tcp port.

Recommending closing this ticket as it is no longer relevant as of Docker Desktop 2.3.0.2.

@mfish0005
Copy link

mfish0005 commented Aug 22, 2020

@artemirq 's Fix worked for me. I don't remember adding that to my .bashrc but it was in there. After removing it my WSL 2 Ubuntu shell can now see the docker daemon

@guobiao-cn
Copy link

ISSUE: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375

!Please follow the order

0. PWOERSHELL

wsl -l -v # ALL DISPLAY "2"

1. LINUX

unset DOCKER_HOST
/etc/init.d/docker restart

2. restart docker

  • windows docker restart
  • windows firewall off

3. LINUX

docker ps

@guybartal
Copy link

ISSUE: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375

!Please follow the order

0. PWOERSHELL

wsl -l -v # ALL DISPLAY "2"

1. LINUX

unset DOCKER_HOST
/etc/init.d/docker restart

2. restart docker

  • windows docker restart
  • windows firewall off

3. LINUX

docker ps

worked for me! thanks!

@therealkenc
Copy link
Collaborator

Porting to discussion as this is a relatively straightforward Windows tcp server listening on a port scenario (similar X11 server etc) with no WSL actionable. Tangentially there are various dupes on improvement of WSL2 networking story in general (#4619, others) but those apply to any Windows host use case, not just Docker server.

@microsoft microsoft locked and limited conversation to collaborators May 10, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests