Docker Community Forums

Share and learn in the Docker community.

WSL and Docker for Windows: "Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?"

This is the responsed for me

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See ‘docker run --help’.

I am having the same problems I have tried following this comments but still having the same error.

assuming that you have used a cmd/powershell window and executed the “docker-machine.exe create default” command …

open the bash shell in WSL

please add the following to your .bashrc file

export VBOX_MSI_INSTALL_PATH=’/c/Program Files/Oracle/VirtualBox/’

export DOCKER_HOST=tcp://192.168.99.101:2376
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=/c/Users//.docker/machine/machines/default
export DOCKER_MACHINE_NAME=default
cd $(pwd | sed ‘s//mnt/c///c//’)

and then execute “source .bashrc”

1 Like

Corrected a typo in the path

Had the same problem. Solved by uninstalling kubernet, minikube; removing all related folders, variables, net configs in hyperv. And then reinstalling docker.

I had the same issue after installing some Windows updates.

What solved it for me initially was: Disable Hyper-V in “Add or remove Windows Features”, restart, enable Hyper-V again, restart again

But now a day later the issue crept back. The solution by nicodocoyo worked like a charm. Run socat via docker on the Windows command line and then connect to the custom port from within WSL.

2 Likes

Works great! Thank you for this solution!

Solved it by resetting Shared Drives credentials :

  1. Go to Shared Drives
  2. Hit Reset credentials
  3. Type password again
  4. Share drive again
  5. Apply

Thanks. This solution works great

Thank you.

I have been struggling with this for well over a year. Some days, connectivity to Docker for Windows works flawlessly within WSL. Other days, the dreaded “Cannot connect to the Docker daemon…” error (usually after Windows updates). No amount of restarting / resetting Docker typically helps, and I often have to reboot numerous times until finally it decides it wants to allow connections again.

Right now, I’m having the issue. I can confirm that running this in cmd.exe and then trying to connect in WSL works. I was concerned that this might break volume mounts from WSL, but they too work perfectly.

Thank you!

Make sure to check the box next to the following:

Docker desktop --> Settings --> General --> “Expose daemon on tcp://localhost:2375 without TLS”

5 Likes

If you are on Windows Pro, you just need to enable on the docker settings {expose demon on port 2375 without TLS} check box.

2 Likes

Thank you so much for this solutin, you saved my day.

I had to expose the 2375 port in the Docker Desktop settings as well. As a test, I quit Docker Desktop and the error returned.

I had these same error message but not that often when I execute docker ps:

Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

Sys info: Running Windows 10 Enterprise Vers 1803 OS Build 17134.1069 and docker ver Docker version 18.09.7, build 2d0083d.

I had tried:

-"/localhost:2375 without TLS" verified it was checked
-Reset permissions to local hard drives
-Restarted docker itself few times

Currently running docker via WSL. Everything works fine but every blue moon I get this error. No matter what I do, it will not go away. My current solution is to do a hard cold restart and everything works as before. I have a theory and it is that docker (or docker-machine and underlined layer) builds up some memory over time until it reaches at limit and the connection cannot be made. Maybe the port is not release properly? It takes on average 10 to 15 days to reach this error and for me, restarting the system solved the problem every time. This has been my experience in the last three months so this behavior of locking up is consistent. I would like to note that after I restart the machine, Docker works without any problems.

Cheers!

The above command needs to be run from the Windows side not the WSL side (thanks bigwhoop). Probably obvious to others but not me :man_facepalming:.

Run socat via docker on the Windows command line (source)

1 Like

He said he has already done it

For anyone still having issues with:

Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

After enabling “Expose daemon on 2375” setting in Docker Desktop, you have to manually restart. I thought it was restarting automatically, but it was not.

5 Likes

I had the same problem with sudo docker <command>.
But without sudo( docker info) it is running fine.

Same issue

wsl:ubuntu $ docker version
Client:
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        369ce74a3c
 Built:             Fri Feb 28 23:45:43 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at tcp://172.18.7.106:2375. Is the docker daemon running?

But in my case it worked from cmd

cmd: $ docker -H tcp://localhost:2375 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

For me helped turn on/off docker’s Expose daemon on tcp://localhost:2375 without TLS setting on windows panel with restart.

wsl:ubuntu $ docker version
Client:
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        369ce74a3c
 Built:             Fri Feb 28 23:45:43 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