我是 Docker 新手。我正在尝试在 Windows 上使用它。
我有 Windows 10 系列,所以我安装了 Linux Bash Shell。
当我运行这个命令时:
$ docker run hello-world
我得到:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
.当我运行时
$ systemctl status docker
我明白了
System has not been booted with systemd as init system (PID 1). Can't operate
最佳答案
对于使用 WSL2 并看到相同错误消息的任何人,请查看 https://github.com/MicrosoftDocs/WSL/issues/457#issuecomment-511495846
电源外壳
wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
Ubuntu$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
$ systemctl status docker
System has not been booted with systemd as init system (PID 1). Can't operate.
$ sudo /etc/init.d/docker start
* Starting Docker: docker [ OK ]
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
关于docker:无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? Windows 10 上的 Linux Bash Shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60935907/