docker安裝出現"Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"


今天按照這個教程使用WSL安裝docker時遇到了個問題:

  • 使用命令:$ docker search mysql

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

進一步測試發現其他命令也都不能使用

必應搜索一番之后找到了一些解決方案:例如這個博客

$ systemctl daemon-reload
$ sudo service docker restart
$ sudo service docker status

不過我在執行第一個命令時就出現了:

System has not been booted with systemd as init system (PID 1). Can't operate

后來找到了這個issue

@craigloewen-msft

"Instead of using sudo systemctl start docker use: sudo /etc/init.d/docker start , as of right now we do not have systemd in WSL 2."

嘗試了sudo /etc/init.d/docker start啟動docker之后便不再出現片頭那個問題

參考資料

https://github.com/MicrosoftDocs/WSL/issues/457

https://www.runoob.com/docker/ubuntu-docker-install.html

https://www.cnblogs.com/mmzs/p/12090197.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM