docker:无法连接到位于的docker守护程序unix:///var/run/docker.sock. docker守护进程正在运行吗?windows 10上的Linux Bash Shell

docker:无法连接到位于的docker守护程序unix:///var/run/docker.sock. docker守护进程正在运行吗?windows 10上的Linux Bash Shell,docker,ubuntu,windows-10,Docker,Ubuntu,Windows 10,我是新来的码头工人。我正在尝试在windows上使用它。 我有Windows 10系列,所以我安装了Linux Bash Shell。 运行此命令时: $ docker run hello-world 我得到: docker:无法连接到位于的docker守护程序unix:///var/run/docker.sock. docker守护进程正在运行吗?。 当我跑的时候 $ systemctl status docker 我明白了 System has not been booted with

我是新来的码头工人。我正在尝试在windows上使用它。 我有Windows 10系列,所以我安装了Linux Bash Shell。 运行此命令时:

$ docker run hello-world
我得到:
docker:无法连接到位于的docker守护程序unix:///var/run/docker.sock. docker守护进程正在运行吗?
。 当我跑的时候

$ systemctl status docker
我明白了

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

您似乎无法在Windows 10
系列中使用docker,因为docker Desktop需要特定的Windows版本,如中所述

系统要求

Windows 10 64位:Pro、Enterprise或Education(Build 15063或更高版本)


您可以尝试在Windows主机上运行基于linux的虚拟机,并在其中运行docker。但是,即使您成功了,您也将失去docker在资源消耗方面的所有优势。

这里的问题是,从错误消息中可以看出,您正在使用WSL(Linux版本1的Windows子系统),此版本没有docker支持,因为它不是完整的Linux内核,但是在Linux用户空间之间有一个转换层,然后转换为Windows内核命令

运行
wsl--list-v
命令将显示您正在使用的版本:

您可以安装WSL版本2,它有一个Microsoft提供的完整Linux内核,使用Hyper-V基础设施(但不是完整的Hyper-V)运行。通过这种方式,它可以在Windows Home、Education和Professional上运行。在这里,您可以运行Linux实例并安装Docker


对于任何使用WSL2并看到相同错误消息的人,请查看

动力壳

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.

你是如何在Windows上安装Docker的?你安装了Docker桌面吗?或Docker Toolbox?错误消息“state”WSL1在哪里?这也是WSL2中的一个问题,有相同的错误消息。@kevlarr OP中的错误消息表明它不是一个完整的操作系统(因此WSL1)WSL2有一个完整的Linux内核——如果我理解正确,则不会给出相同的错误消息。感谢澄清这个假设。WSL2上实际上收到了相同的错误消息(至少对我来说),这显然与
systemctl
不可用有关。