WSL - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

In my case it appears that WSL Integration was turned on in the “General” settings, but not enabled for my specific WSL distro. After enabling integration with additional distros, I was back up and running.

Had the same issue and this solved it

Solved my problem. It was unchecked after a upgrade of Docker Desktop and a reboot of my machine.
Thanks


why i dont see this option?

i try to do but it didint work

The message shows you exactéy why. Run

wsl --list --verbose

You should see at least one WSL distribution in addition to docker-desktop and docker-desktop-data and the version numbers should all be 2, not 1.

If you don’t have a WSL distribution, you have to install one from the store. Since you shared your issue in this topic about accessing the docker socket, I guess you have a distribution, but not a WSL2 distro.

The solution you quoted was not for Docker Desktop.

I fix that problem
i do these steps:
In my opinion, the main problem here is the way we install Ubuntu. Now let me tell you what happened to me. I had one Ubuntu account, so I did “docker login” and “sudo docker server start”, but when I did “docker server status”, the servers still appeared offline, so I fixed the problem. For this, I installed Ubuntu via Powershell and thus I had 2 Ubuntu accounts. After that, I tried the same codes again using “my account that I opened from Powershell” and the problem was solved. I hope also if these do not work, “wsl --update” You can also try the command I hope this info solve yours problems have a nice day!

This solved my issues. Thanks for the tip

As WSL Integration was already enabled, it was solved by restarting WSL.

I got this error

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

after upgrading to Docker Desktop 4.39.0
(Windows 10 Home)

Back to working condition after downgrade to 4.38.0.

Same exact problem when updating from 4.38.0 to 4.39 at the time. I had to roll back to 4.38. Now that it’s been a number of months, I just tried again and updated to 4.44.1, but the same thing is happening.

I’m using OpenSUSE WSL2.

docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

“Use the WSL 2 based engine” is checked.

wsl 2 integration is enabled

I tried resetting Windows docker desktop, rebooting, unchecking and rechecking all the boxes, but nothing. Yet, after downgrading to 4.38, it works again. What can this be?

I did a clean install of another separate WSL 2 OpenSUSE distro, and… docker is available in it, it works. So something is preventing it from working with my existing distro… which I now have to blow up and migrate, I suppose.

After examining the processes running on a working distro vs one that stopped working, I found that the working one had this process running, but the broken one did not:

/mnt/wsl/docker-desktop/docker-desktop-user-distro proxy --distro-name openSUSE-Leap-15.6 --docker-desktop-root /mnt/wsl/docker-desktop “C:\Program Files\Docker\Docker\resources”

After adjusting the distro name and running this command as root manually, docker functionality started working on the broken distro!

So 4.38.0 was the last version of Docker Desktop to properly set this up for some reason, and all follow-up versions have broken this. Now to bring this to the core team’s attention…

Edit: Reported the bug here: "docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" after updating to any version from 4.38.0 · Issue #14905 · docker/for-win · GitHub.

to me was a bit different, as /mnt/wsl/shared-docker didn’t exist

home:/mnt/wsl/docker-desktop$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///mnt/wsl/shared-docker/docker.sock. Is the docker daemon running?

Run ‘docker run --help’ for more information
home:/mnt/wsl/docker-desktop$ ls /mnt/wsl/shared-docker
ls: cannot access ‘/mnt/wsl/shared-docker’: No such file or directory

You can also search in the /mnt/wsl by “docker.sock” with the following command:

home:mnt/wsl$ find . -name “docker.sock”
./docker-desktop-bind-mounts/Ubuntu/docker.sock

then export the “docker.sock”

export DOCKER_HOST=unix:///mnt/wsl/docker-desktop-bind-mounts/Ubuntu/docker.sock

docker version

docker images

voila; issue gone

docker context list
NAME DESCRIPTION DOCKER ENDPOINT ERROR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock
desktop-linux Docker Desktop npipe:////./pipe/dockerDesktopLinuxEngine

docker context use default

or set this one and restart WSL integration(disable and enable it again)

make sure there’s no $DOCKER_HOST
home:/mnt$ echo $DOCKER_HOST # should print empty line as void

If you get this error trying to use docker-ce in WSL (without Docker Desktop):

  • Stop Docker Desktop (tray icon)
  • In WSL,
    • Uninstall docker-ce
    • Re-install docker-ce

My use case: Docker Desktop cannot access WSL’s VSOCK socket, but docker-ce can.

If you want to stop using Docker Desktop and use only Docker CE in WSL2, you don’t nead to uninstall an already installed Docker CE. You can restart the Docker socket service

systemctl restart docker.socket

Just to be safe you can restart the docker service as well, but uninstalling Docker CE should not be needed. I test Docker CE and Docker Desktop on the same Windows sometimes. both works, you just need to be aware that Docker Desktop doesn’t need Docker CE, so when you run both, Docker Desktop can override the socket and you can only connect to Docker Desktop, so when you stop the desktop, the socket will not work until rhe docker socket service recreates it.

Thanks very much for this ansuerd. My problem as been solved