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

Hi guys.

I’m using WSL on Windows 11 and installed Docker following instructions from Docker documentation - Install Docker Engine on Ubuntu | Docker Documentation

renatospaka@LINA-QG:~/dev$ docker version
Client: Docker Engine - Community
 Version:           20.10.9
 API version:       1.41
 Go version:        go1.16.8
 Git commit:        c2ea9bc
 Built:             Mon Oct  4 16:08:29 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

However, it is not working as per the following error:

renatospaka@LINA-QG:~/dev$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

This is my WSL/Ubuntu setup:

renatospaka@LINA-QG:~/dev$ cat /etc/os-release
VERSION="20.04 LTS (Focal Fossa)"
PRETTY_NAME="Ubuntu 20.04 LTS"


Hi, WSL does not have systemd. I have Windows 10, but I don’t think it is different in Windows 11.
Every time you start the WSL distro you have to start the docker service:

sudo service docker start


Hi ,
correct, WSL does not have systemd, It is said on the Internet that it may also be because the docker service is not started, so I used another command:
sudo service docker start
and system shows: * Starting Docker: docker
it seem like run, I run this command:
sudo service docker status
but system show : * Docker is not running
I tried lots of time but it still not running…,can you help me, thank very much!

It was just yesterday when I helped a colleague with the same issue. In his case WSL got an IP address colliding with the Docker network, so he had to change either the network of WSL or Docker. Changing Docker network was easier, so I recommended to do that. Create or edit /etc/docker/daemon.json and add an address pool setting:

  "default-address-pools": [
      "base": "",
      "size": 24

It could also be:

  "default-address-pools": [
      "base": "",
      "size": 24

or anything that is available in your network.

It is just an example. Make sure you don’t set a pool colliding with your local network. If you already tried to change the network of WSL, reset all the changes and reboot Windows so it can create the WSL network again.

The other, harder approach is creating a network adapter on the host which covers the IP addresses of Docker, so WSL can’t use that and it will choose an available IP address from


I realized that the described configuration above was not the solution of the issue, but it happened during the configuration which was required to fix the network. At a point, Docker could not start. You can check the log file:

sudo cat /var/log/docker.log

In my case the problem was that the installation of docker expects to listen events from another socket.

I went to /var/log/docker.log and the last line of the log was saying:

“API listen on /mnt/wsl/shared-docker/docker.sock”

So wat i did was: go to /var/run and run:

sudo rm docker.sock && sudo ln -s /mnt/wsl/shared-docker/docker.sock /var/run/docker.sock

Basically I created a symbolic link between the two sockets. This fixed the issue.

1 Like

Thank you! This resolved my problem to run docker with “-H” flag every time.