Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Ubuntu 20.04 ,WSL2)

6.6k views Asked by At

I have Microsoft Windows 10 Pro version 10.0.19041 N/A Build 19041 and I follow steps here https://learn.microsoft.com/en-us/windows/wsl/install-win10 to install Ubuntu 20.04 LTS on it using WLS2 , I'm doing so to install docker by following steps here https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository but when I try to run sudo docker run hello-world it gives me this error docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'. I know that a similar question asked here Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? ,and I try to run systemctl daemon-reload and systemctl start docker but al the solutions does not worked for me it gives me another errors like System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down and Also try to fix it but I can't, So I need your help.

Note : I have already install Docker in windows and It works fine.

1

There are 1 answers

0
Alaa Radwan On

I have been solving this problem by following these steps

  1. Purge the Grub package Linux command according this issue https://github.com/microsoft/WSL/issues/4903

  2. Stop Docker Desktop from Windows

  3. Run sudo dockerd which is the daemon service for Docker containers https://i.stack.imgur.com/qgbwE.png

  4. Open new Ubuntu shell session

  5. Run docker run hello-world

and it's work fine with me https://i.stack.imgur.com/6TJ3u.png