为什么 Docker 服务停止了?

Esp*_*pen 5 windows ubuntu docker windows-subsystem-for-linux

我将 Ubuntu 作为 Windows 10 上的子系统运行。

我刚刚按照在 Linux 上安装 Docker 的步骤: https ://docs.docker.com/install/linux/docker-ce/ubuntu/

现在正在测试 hello-world 应用程序:

$ sudo docker run hello-world
Run Code Online (Sandbox Code Playgroud)

我在哪里收到此错误:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Run Code Online (Sandbox Code Playgroud)

我已将范围缩小到它实际上是未运行的服务 - 尽管网上有许多其他解决方案或多或少修复了此类错误。

当我检查状态时:

$ sudo service docker status
* Docker is not running
Run Code Online (Sandbox Code Playgroud)

它说它没有运行,所以我成功启动它:

$ sudo service docker start
* Starting Docker: docker                                                                                       [ OK ]
Run Code Online (Sandbox Code Playgroud)

如果我立即检查状态,它会说它正在运行。但是当我几秒钟后再次检查它时,它没有运行:

$ sudo service docker status
* Docker is running

$ sudo service docker status
* Docker is not running
Run Code Online (Sandbox Code Playgroud)

Docker 服务为何停止​​以及如何保持其运行?

atl*_*ine 3

你得到的正如预期的那样。

\n\n

Microsoft 不支持在 WSL 实例中运行 Docker 守护程序(也称为服务)。你可以参考这个讨论

\n\n

您可以做的就是docker client在 WSL 中使用连接到远程 docker 引擎,这意味着docker daemon仍在其他 PC 上。

\n\n

但是,如果你使用的是WSL2May 6th, 2019,那么从微软的公告来看,可能是这样的(这个公告里还有一个demo,你可以看一下):

\n\n
\n

今天,我们\xe2\x80\x99 揭开了适用于 Linux 的 Windows 子系统的最新架构:WSL 2!这个新架构中的变化将实现:文件系统性能的显着提高以及完整的系统调用兼容性,这意味着您可以在 WSL 2 中运行更多 Linux 应用程序,例如 Docker。

\n
\n