【问题标题】:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Linux Bash Shell on windows 10docker:无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? Windows 10 上的 Linux Bash Shell
【发布时间】:2020-03-30 17:17:32
【问题描述】:

我是 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

【问题讨论】:

  • 你是如何在 Windows 上安装 Docker 的?你安装了 Docker 桌面吗?还是 Docker 工具箱?

标签: docker ubuntu windows-10


【解决方案1】:

对于使用 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.

【讨论】:

  • 使用您提供的命令启动但没有工作 ``` $ sudo /etc/init.d/docker start * 启动 Docker: docker [ OK ] $ docker ps 无法连接到 Docker unix:///var/run/docker.sock 的守护进程。 docker 守护进程是否正在运行? ```
  • 如何使用sudo,例如。 sudo docker ps?
【解决方案2】:

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

系统要求

Windows 10 64 位:专业版、企业版或教育版(内部版本 15063 或更高版本)。

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

【讨论】:

    【解决方案3】:

    这里的问题是,从错误消息中,它表明您正在使用 WSL(Linux 版本 1 的 Windows 子系统),此版本不支持 Docker,因为它不是完整的 Linux 内核,而是翻译Linux 用户空间之间的层,然后转换为 Windows 内核命令。

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

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

    Windows Subsystem for Linux Installation Guide

    【讨论】:

    • 错误消息“状态”WSL1 在哪里?这也是 WSL2 中的一个问题,带有相同的错误消息。
    • @kevlarr OP 中的错误消息表明它不是一个完整的操作系统(因此 WSL1)WSL2 有一个完整的 Linux 内核——如果我理解正确,不会给出相同的错误消息跨度>
    • 啊,感谢您澄清假设。实际上在 WSL2 上收到了相同的错误消息(至少对我而言),它显然与 systemctl 不可用有关。
    猜你喜欢
    • 2022-07-07
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多