当前位置:   article > 正文

docker 在ubantu18.0.4上安装遇到的问题failed to start daemon: Error initializing network controller: error obt

failed to start daemon: error initializing network controller: error obtaini

启动docker时候报错

sudo systemctl start docker
  • 1
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
  • 1
  • 2

查看服务状态

systemctl status docker.service
  • 1
Dec 20 10:50:53 dell-08 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Dec 20 10:50:53 dell-08 systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Dec 20 10:50:53 dell-08 systemd[1]: Stopped Docker Application Container Engine.
Dec 20 10:50:53 dell-08 systemd[1]: docker.service: Start request repeated too quickly.
Dec 20 10:50:53 dell-08 systemd[1]: docker.service: Failed with result 'exit-code'.
Dec 20 10:50:53 dell-08 systemd[1]: Failed to start Docker Application Container Engine.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

查看日志信息

 journalctl -u docker.service
  • 1
Dec 20 09:47:19 dell-08 systemd[1]: Starting Docker Application Container Engine...
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.785505287+08:00" level=info msg="Starting up"
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.786331056+08:00" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/resolv.conf"
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.883310307+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.883859748+08:00" level=info msg="Loading containers: start."
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.889121555+08:00" level=warning msg="failed to find iptables" error="exec: \"iptables\": executable file not found in $PATH"
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.890948078+08:00" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
Dec 20 09:47:19 dell-08 dockerd[9897]: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: Iptables not found
Dec 20 09:47:19 dell-08 dockerd[9897]: time="2023-12-20T09:47:19.891967113+08:00" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby
Dec 20 09:47:19 dell-08 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Dec 20 09:47:19 dell-08 systemd[1]: docker.service: Failed with result 'exit-code'.
Dec 20 09:47:19 dell-08 systemd[1]: Failed to start Docker Application Container Engine.
Dec 20 09:47:21 dell-08 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

原因

这些错误表明 Docker 无法找到 iptables 命令,它是用于配置网络规则和转发的重要工具。缺少 iptables 可能会导致 Docker 无法初始化网络控制器,从而无法启动。
1.检查 iptables 是否已正确安装在系统上。您可以在终端中运行以下命令来检查:

which iptables
  • 1

2.如果 iptables 未安装,请根据您使用的操作系统和软件包管理器执行适当的安装命令。例如,对于基于 Debian 的系统(如 Ubuntu),您可以运行以下命令来安装 iptables:

 sudo apt-get update
 sudo apt-get install iptables
  • 1
  • 2

3.确保 iptables 被正确配置,并且其可执行文件位于系统的可执行路径中。您可以使用以下命令验证 iptables 的位置:

 echo $PATH
  • 1

确保输出中包含 /sbin/usr/sbin 目录,这些目录通常包含 iptables 可执行文件。

再次开启docker

sudo systemctl start docker
  • 1

查看状态

 systemctl status docker.service
  • 1

如果还是不行,并且提示 iptables已经存在

sudo apt-get install --reinstall iptables
  • 1

使用这个命令可以重新安装

造成这个不能使用的原因:个人遇到 1.重启(但是别的服务器没有问题)2.中病毒(服务器中了挖矿病毒,之前杀毒的时候遇到过这个问题,病毒会修改某个组件的命令让其不可用)

which iptables
  • 1

在这里插入图片描述
注意:路径可能不同 但是有输出应该没问题

sudo systemctl start docker
  • 1

the end…

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号