简体   繁体   中英

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

I have Microsoft Windows 10 Pro version 10.0.19041 N/A Build 19041 and I follow steps here https://docs.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.

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 disktop 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM