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'.
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:
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!
regards,
DB
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:
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 192.168.0.0/16.
Update
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:
Check that WSL distro is enabled for Docker integration. In Docker Desktop, go to Settings > Resources > WSL INTEGRATION and make sure that the checkbox next to your WSL distro is checked.
So you didn’t look in the docs at all? Either prefix your command with sudo or apply what is written in the post installation steps and then use the docker cli without sudo.
In my case, the checkbox for “Enable integration with my default WSL distro” in Docker settings/resources somehow unchecked itself. Rechecking and restarting resolved my issue.