【问题标题】:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Ubuntu 20.04 ,WSL2)无法连接到 unix:///var/run/docker.sock 上的 Docker 守护程序。 docker 守护进程是否正在运行? (Ubuntu 20.04,WSL2)
【发布时间】:2021-01-13 11:23:50
【问题描述】:

我有 Microsoft Windows 10 Pro 版本 10.0.19041 N/A Build 19041,我按照步骤操作这里 https://docs.microsoft.com/en-us/windows/wsl/install-win10 使用 WLS2 在其上安装 Ubuntu 20.04 LTS ,我这样做是为了安装 docker按照这里的步骤https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository 但是当我尝试运行sudo docker run hello-world 时,它给了我这个错误docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock。 docker 守护进程是否正在运行? 请参阅 'docker run --help'。 我知道在 Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? 此处提出了类似的问题,我尝试运行 systemctl daemon-reloadsystemctl start docker 但所有解决方案都对我不起作用,它给了我另一个像 之类的错误系统尚未使用 systemd 作为 init 系统 (PID 1) 启动。不能操作。 无法连接到总线:主机已关闭,也尝试修复它,但我不能,所以我需要你的帮助。

注意:我已经在 windows 中安装了 Docker,它运行良好。

【问题讨论】:

  • systemctl status docker 说什么?
  • 系统尚未使用 systemd 作为初始化系统 (PID 1) 启动。不能操作。无法连接到总线:主机已关闭

标签: windows docker docker-compose ubuntu-20.04 wsl-2


【解决方案1】:

我已经按照这些步骤解决了这个问题

1-根据这个问题https://github.com/microsoft/WSL/issues/4903清除grub包linux命令

2- 从 windows 停止 docker disktop

3- 运行 sudo dockerd 这是 docker 容器的守护进程服务 https://i.stack.imgur.com/qgbwE.png

4-打开新的 ubuntu shell 会话

5-运行docker run hello-world

它对我来说很好https://i.stack.imgur.com/6TJ3u.png

【讨论】:

    猜你喜欢
    • 2017-11-24
    • 1970-01-01
    • 2022-07-07
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多