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