记一次docker启动报错Error starting daemon: Error initializing network controller:…….Iptables not found
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2024-02-19 14:02:02 CST; 28s ago
Docs: http://docs.docker.com
Process: 1171 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 1171 (code=exited, status=1/FAILURE)
一、错误提示
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: Iptables not found
docker.service: main process exited, code=exited, status=1/FAILURE
Failed to start Docker Application Container Engine.
Unit docker.service entered failed state.
docker.service failed.
在网上搜索的方法大多数都是进行删除 /var/lib/docker/network,然后进行重启,然而并没啥卵用。
二、解决方法
报错结尾写明没有找到iptables
#安装iptables
yum install -y iptables
#升级iptables
yum update iptables
#安装iptables-services
yum install iptables-services
# 更改了网络配置,重启加载网络配置
source /etc/profile
#重启docker
systemctl restart docker
进行启动 成功!
三、修改配置为阿里云yun源
##切换目录到本地yum源地址
[root@localhost ~]# cd /etc/yum.repos.d
##创建一个文件
[root@localhost yum.repos.d]# mkdir back
##将所有.repo文件转移到刚创建的目录下
[root@localhost yum.repos.d]# mv *.repo back
##自己ls 看一下是否清除
##下载安装weget以防万一本机没有weget命令
[root@localhost ~]# yum -y install weget
###下载aliyun的yum源(更换主yum源为国内的阿里云yum源)
[root@linux-server yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
##参数解释
curl -o 指定存放路径
##(知识拓展下面一条为扩展源)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
安装扩展源--epel.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
##进入到yum源地址进性查看
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo epel.repo (安装成功)
## 清理旧缓存数据,缓存新数据
yum clean all
## 把服务器的包信息下载到本地电脑缓存起来
yum makecache
出现metadata cache created(中文下显示为“元数据缓存已建立”)即已完成配置,入下图。