转自:https://blog.csdn.net/wohaqiyi/article/details/84450562

docker运行报错docker0: iptables: No chain/target/match by that name.
  最近在一个新的服务器上装服务,没有安装iptables ,后来安装了iptables 之后,忽然发现我的docker 不能运行了。
  注意,可能别人的不行,我这个原因是,开始在新服务器上没有安装iptables ,先安装的docker ,后来才停用默认的firewall ,安装了iptables,就出现了这样的问题。其他原因,我不知道这方法可行不?先看错误:
  运行时报出了以下错误:
————————————————

启动docker服务报错
Error response from daemon: No such container: yn-userservice-
26126ca87430b74c3987817492cc890e72c36e2fec10d807e362a12f22365160
/usr/bin/docker-current: Error response from daemon: driver failed programming external
connectivity on endpoint yn-userservice- (5d083ef51f932ac24936713ab3bc1cece9d47feabf4a916cf5da12a4fb2a122a):
(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d / --dport -j DNAT --to-
destination 172.17.0.2: ! -i docker0: iptables: No chain/target/match by that name.

后来在网上找了下,发现解决办法很简单,如下:

1、停止docker服务

  输入如下命令停止docker服务

systemctl stop docker  或者service docker stop

停止成功的话,再输入docker ps 就会提示出下边的话:

Cannot connect to the Docker daemon. Is the docker daemon running on this host?
2、保存 iptables

  输入如下命令:

iptables-save >  /etc/sysconfig/iptables

我发现 防火墙的配置文件/etc/sysconfig/iptables前后文件如下,当然我是看不懂了,我也就会设置个入站端口
  保存之前文件内容:

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [:]
:FORWARD ACCEPT [:]
:OUTPUT ACCEPT [:]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

保存之后的文件内容:

# Generated by iptables-save v1.4.21 on Sat Nov  ::
*nat
:PREROUTING ACCEPT [:]
:INPUT ACCEPT [:]
:OUTPUT ACCEPT [:]
:POSTROUTING ACCEPT [:]
COMMIT
# Completed on Sat Nov ::
# Generated by iptables-save v1.4.21 on Sat Nov ::
*filter
:INPUT ACCEPT [:]
:FORWARD ACCEPT [:]
:OUTPUT ACCEPT [:]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Sat Nov ::
3、启动docker服务

  保存了iptables后,可以重新启动docker了。输入如下命令:

systemctl start docker 或者service docker  start
4、将docker设置为开机启动

  设置过这个就不需要再设置了

systemctl enable docker
5、启动容器

  最后启动容器,发现不再报错了。

docker start 容器id/名字

docker运行报错docker0: iptables: No chain/target/match by that name.的更多相关文章

  1. Docker 启动时报错:iptables:No chain/target/match by the name

    重新启动docker后,就好了. service docker restart

  2. iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker0: iptables: No chain/target/match by that name

    今天使用docker运行mysql时报错, 执行命令: docker run --restart=always --name mysql5.7 -p 3306:3306 -v /data/mysql/ ...

  3. iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8001 -j DNAT --to-destination 172.17.0.5:8080 ! -i docker0: iptables: No chain/target/match by that name.

    在docker容器上部署项目后,启动docker容器,出现 iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dpor ...

  4. 【Docker】iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8480 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name

    启动容器的时候,出现如下错误: Error response / --dport -j DNAT --to-destination ! -i docker0: iptables: No chain/t ...

  5. centos6.8 docker0: iptables: No chain/target/match by that name

    现象:之前docker gitlab运行的一直好好的,突然有一天访问不了,但容器却还运行着.于是我把gitlab容器重启,发现启动不了了,报错:docker0: iptables: No chain/ ...

  6. centos7 解决docker0: iptables: No chain/target/match by that name

    解决步骤: 1.查看iptables状态,查看是否正常docker需要依赖该服务 service iptables status 注:我都服务就发现iptables服务的有问题 2.查看iptable ...

  7. 启动docker容器 防火墙问题报错 ! -i docker0' failed: iptables: No chain/target/match by that name.

    COMMAND_FAILED: '/sbin/iptables -t nat -A DOCKER -p tcp -d 0/0 --dport 8111 -j DNAT --to-destination ...

  8. arm,iptables: No chain/target/match by that name.

    最近由于项目需要,需要打开防火墙功能. 公司有 arm linux 3.0x86 linux 3.2x86 linux 2.4 的三个嵌入式.都需要打开防火墙功能. 执行“whereis iptabl ...

  9. [转]启动container的时候出现iptables: No chain/target/match by that name

    本文转自:https://blog.csdn.net/u013948858/article/details/83115388 问题: Error response from daemon: drive ...

随机推荐

  1. git lfs setpu(4)

    reference: https://packagecloud.io/github/git-lfs/installhttps://zzz.buzz/zh/2016/04/19/the-guide-to ...

  2. luogu P4194 矩阵

    嘟嘟嘟 先二分. 令二分的值为\(mid\),则对于每一行都要满足\(|\sum_{i = 1} ^ {n} (A_{ij} - B_{ij})|\),把绝对值去掉,就得到了\((\sum_{i = ...

  3. AcWing:238. 银河英雄传说(带权并查集)

    有一个划分为N列的星际战场,各列依次编号为1,2,…,N. 有N艘战舰,也依次编号为1,2,…,N,其中第i号战舰处于第i列. 有T条指令,每条指令格式为以下两种之一: 1.M i j,表示让第i号战 ...

  4. LG5283 异或粽子

    题意 共有\(n\)个数,选择\(k\)个不同的\([l,r]\)区间,使得它们的异或和最大 $ 1 \leq n \leq 5 \times 10^5,k \leq 2 \times 10^5$ 思 ...

  5. vue 复制内容到粘贴板

    首先是npm安装依赖包:npm install clipboard --save 导入组件:import Clipboard from "clipboard"; html如图: c ...

  6. CPU分支预测器

    两篇结合就ok啦 1.https://www.jianshu.com/p/be389eeba589 2.https://blog.csdn.net/edonlii/article/details/87 ...

  7. SpringCloud(二)之Ribbon的实现负载均衡的基本应用

    一 Ribbon简介     Ribbon是Netflix发布的负载均衡器,它是一个基于HTTP和TCP的客户端负载均衡工具,它基于Netflix Ribbon实现.通过Spring Cloud的封装 ...

  8. awk 分组求和

    awk 分组求和 分组求和 awk '{s[substr($2,1,6)] += $1} END{for(i in s) {print i, s[i]/(1024*1024*1024)} }' fil ...

  9. Message NNNN not found; No message file for product=network, facility=TNS

    Message NNNN not found; No message file for product=network, facility=TNS Table of Contents 1. 错误信息 ...

  10. Jmeter 时间函数

    1.参数值是日期,而日期是当前时间:用__time函数,生成任意格式时间 把生成的函数字符串直接复制粘贴即可使用 2.参数是昨天或者明天,即以当前时间为基准,增加或减少固定时间的,可以用__timeS ...