docker - 启动失败,因为找不到 /etc/fstab

qwa*_*g07 7 docker windows-subsystem-for-linux debian-stretch

我正在使用 Window Linux 子系统(Debian 延伸版)。按照 Docker 网站上的说明,我安装了 docker-ce,但无法启动。这是信息:

$ sudo service docker start
grep: /etc/fstab: No such file or directory
[ ok ] Starting Docker: docker.
$ sudo service docker status
[FAIL] Docker is not running ... failed!
Run Code Online (Sandbox Code Playgroud)

/etc/fstab找不到怎么办?

Moc*_*cXi 14

修复 fstab

touch /etc/fstab
Run Code Online (Sandbox Code Playgroud)

如果你运行dockerd,它会给你失败的消息:

INFO[2022-01-27T17:55:14.100489400+07:00] Loading containers: start.
WARN[2022-01-27T17:55:14.191666800+07:00] Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.2 (nf_tables):  CHAIN_ADD failed (No such file or directory): chain PREROUTING`, error: exit status 4
INFO[2022-01-27T17:55:14.493716300+07:00] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
INFO[2022-01-27T17:55:14.494906600+07:00] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
INFO[2022-01-27T17:55:14.495048400+07:00] stopping healthcheck following graceful shutdown  module=libcontainerd
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables --wait -t nat -N DOCKER: iptables v1.8.2 (nf_tables):  CHAIN_ADD failed (No such file or directory): chain PREROUTING
 (exit status 4)
Run Code Online (Sandbox Code Playgroud)

这是 Debian nat 问题,修复它:

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
Run Code Online (Sandbox Code Playgroud)

现在您可以再次启动该服务

您可以按照此操作使其在启动时启动https://askubuntu.com/a/1356147/138352

编辑:

如果 IP 表问题仍然存在,请尝试将WSL 版本设置为 2,从 Windows shell 运行命令:

wsl --set-version <distribution name> 2
Run Code Online (Sandbox Code Playgroud)

可以使用命令找到通讯组列表wsl -l


Ada*_*ise 10

我遇到了同样的错误。显然,在我使用 Debian 安装 WSL 时,我没有 etc/fstab 文件。令人惊讶的是,只需通过“触摸”创建文件即可:

sudo touch /etc/fstab
Run Code Online (Sandbox Code Playgroud)

  • 不适用于使用 Debian 10 的 Wsl2,但是 [this](/sf/answers/4961427971/) 有所帮助。 (2认同)

小智 2

也许是一个很好的信号https://learn.microsoft.com/en-us/windows/wsl/release-notes#build-17093

WSL 现在在实例启动期间处理 /etc/fstab 文件 [GH 2636]。