Docker 在没有 Docker 桌面的 WSL 下

Docker under WSL without Docker Desktop

这是关于 运行ning Docker 的问题,来自 WSL,没有 Docker DesktopIt is doable for WSL2,所以本题的重点具体在WSL1上。在我的研究中,

我的 docker 是 debian bullseye 下的 20.10.5。还会好吗?

我试过了,得到了:

iptables can't initialize iptables table `nat': Table does not exist

的答案是

According to the Microsoft WSL page on github.com, iptables isn't supported.

https://github.com/Microsoft/WSL/issues/767

但那是 4 年多以前的事了,因为它可能在 2019 年晚些时候出现,所以我想知道最新的状态是什么。

WSL1 - The little engine that could(包含 link,因为该引用可能仅被有限的受众理解)。

不幸的是,在 Docker 的情况下,WSL1 引擎似乎 运行 失去了动力。在阅读您引用的那个博客 post 以及相应的 Github thread 时,我非常惊讶人们 did 与 运行宁Docker。我以前从没见过。

但是,如果您阅读了 Github 线程中的完整评论,那么结果似乎相当有限。将这些摘录按顺序排列:

[2018-04-23] I'm glad to say Docker daemon finally runs on WSL. I'm testing on build 17134. ... The last docker-ce version that works right now on build 17134 is 17.09.0. Anything after that fails on extracting the docker images.

请注意,它必须(并且仍然必须)在 WSL1 实例中 运行 作为 Windows 管理员.

[2018-0612] Unfortunately, docker-compose still doesn't work.... There is a problem with iptables which is not fully supported via WSL yet.

(你 运行 喜欢哪个,虽然我没看到。也许是“管理员”的事?)

[2018-07-09] Yeah, I recently mentioned it on Twitter and got a major "we aren't supporting this, we highly advise against it" message from our former WSL PM.

[2018-11-13] WSL PM here. As mentioned in the above comment, we have improved Docker support in recent builds of WSL. Most (if not all) versions of docker-ce work with WSL. We're working on a large set of changes for WSL currently. As part of those changes, we are looking at adding native Docker support in WSL. I will add to this thread and other issues on Docker support when I have additional updates to share

这似乎没有任何进展,因为至少 PM 再也没有 post 在线程中编辑过。

[2019-04-18] Like others have pointed out, running docker 17.09 works. Anything later fails with different errors. It might be that newer docker versions are using other syscalls not yet implemented by WSL.

这里散布了一些关于 运行 --network host(对于客户端)或 --iptables=false(对于守护程序)的其他消息。

[2019-08-04] Windows Insider Fast Ring build (>=18917) via WSL2, latest docker/docker-compose is running native in WSL Linux.

并且在 2020 年末,线程消失了。

在测试 WSL1 Ubuntu 20.04 实例中,我能够获得 hello-world 运行ning,但仅此而已。 运行 busyboxubuntu 图像(有或没有交互式终端)失败:

Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: waiting for init preliminary setup: EOF: unknown.

一旦焦点转移到 WSL2 和真正的内核,在我看来,WSL 团队在推进 WSL1 的 pseudo-kernel 系统调用翻译层方面没有取得任何进展。