为什么 Docker 服务停止了?

Why is the Docker service stopping?

我 运行 Ubuntu 作为 Windows 10 的一个子系统。

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

现在正处于测试 hello-world 应用程序的阶段:

$ sudo docker run hello-world

我在哪里得到这个错误:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

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

当我查看状态时:

$ sudo service docker status
* Docker is not running

说不是运行所以我启动成功了:

$ sudo service docker start
* Starting Docker: docker                                                                                       [ OK ]

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

$ sudo service docker status
* Docker is running

$ sudo service docker status
* Docker is not running

为什么 Docker 服务停止了,我该如何保持它 运行?

您在 Windows 上需要 Docker: https://medium.com/@sebagomez/installing-the-docker-client-on-ubuntus-windows-subsystem-for-linux-612b392a44c4

如你所愿。

Microsoft 在 WSL 实例中不支持 运行 Docker 守护程序(也称为服务)。可以参考this discussion.

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

但是,如果你使用May 6th, 2019中公布的WSL2,那么从微软的公布来看,可能是(这个公布中也有一个demo,你可以看看):

Today we’re unveiling the newest architecture for the Windows Subsystem for Linux: WSL 2! Changes in this new architecture will allow for: dramatic file system performance increases, and full system call compatibility, meaning you can run more Linux apps in WSL 2 such as Docker.