今天按照這個教程使用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
"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