我是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
答案 0 :(得分:2)
似乎您将无法在Windows 10 family
中使用docker,因为docker Desktop需要特定的Windows版本,如official documentation中所述。
系统要求
Windows 10 64位:专业版,企业版或教育版(内部版本15063或更高版本)。
您可以尝试的是在Windows主机上运行基于Linux的虚拟机,然后在其中运行docker。但是即使成功,您也将失去docker在资源消耗方面的所有优势。
答案 1 :(得分:0)
对于使用 WSL2 并看到相同错误消息的任何人,请查看 https://github.com/MicrosoftDocs/WSL/issues/457#issuecomment-511495846
Powershell
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.
答案 2 :(得分:-1)
这里的问题是,从错误消息中,它指出您使用的是 WSL(Linux 版本 1 的 Windows 子系统),此版本没有 Docker 支持,因为它不是完整的 Linux 内核,而是一个翻译Linux 用户空间之间的层,然后转换为 Windows 内核命令。
运行 wsl --list -v
命令将显示您正在使用的版本:
您可以安装 WSL 版本 2,它具有 Microsoft 提供的使用 Hyper-V 基础架构(但不是完整的 Hyper-V)运行的完整 Linux 内核。这样它就可以在 Windows Home、Education 和 Professional 上运行。在这里,您可以运行 Linux 实例并安装 Docker。