Docker 守护进程无法运行“MASQUERADE”:没有此文件或目录

Docker 守护进程无法运行“MASQUERADE”:没有此文件或目录

我在 Ubuntu 21.04 上安装和运行 docker 守护程序时遇到了一些问题。

在安装软件包期间我收到了以下失败消息:

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2022-03-26 15:59:32 UTC; 13ms ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 47139 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
   Main PID: 47139 (code=exited, status=1/FAILURE)
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)

当我尝试获取有关该问题的更多信息时,我dockerd --debug得到了以下信息:

failed to start daemon: Error initializing network controller: Error creating default "bridge" network: Failed to Setup IP tables: Unable to enable NAT rule:  (COMMAND_FAILED: '/usr/sbin/iptables -w10 -t nat -I POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE' failed: iptables v1.8.7 (legacy): Couldn't load target `MASQUERADE':No such file or directory

我尝试清除已安装的所有 docker,然后重新启动并重试安装,但结果还是一样。

我也尝试过iptables这样重新安装sudo apt-get install --reinstall iptables但是它给出了与安装 docker 相同的失败:

sudo apt-get install --reinstall iptables
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/430 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 121818 files and directories currently installed.)
Preparing to unpack .../iptables_1.8.7-1ubuntu2_amd64.deb ...
Unpacking iptables (1.8.7-1ubuntu2) over (1.8.7-1ubuntu2) ...
Setting up iptables (1.8.7-1ubuntu2) ...
Setting up docker-ce (5:20.10.14~3-0~ubuntu-hirsute) ...
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2022-03-26 16:04:24 UTC; 9ms ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 47622 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
   Main PID: 47622 (code=exited, status=1/FAILURE)

Mar 26 16:04:24 ubuntu systemd[1]: Failed to start Docker Application Container Engine.
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)

我在 Chromebook 笔记本电脑上的 USB 上运行 Ubuntu,使用呼吸如果它可以帮助我的情况。

我认为可能docker0没有设置但是运行时它似乎在这里ip link show

lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: wlp0s12f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether cc:f9:e4:cc:10:b9 brd ff:ff:ff:ff:ff:ff
3: docker0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default 
    link/ether 02:42:c9:dc:1a:35 brd ff:ff:ff:ff:ff:ff

是不是我做错了什么?或者与我的设置有关?

相关内容