docker端口映射或启动容器时报错

docker端口映射或启动容器时报错

原始镜像如下:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
xtjatswc/mycore2    v3                  73ce3cd97c01        About an hour ago   1.74GB
xtjatswc/mycore     latest              73ce3cd97c01        About an hour ago   1.74GB
microsoft/dotnet    latest              521411f3b61d        4 days ago          1.73GB

用docker tag 命令修改镜像REPOSITORY、TAG后,如下

[root@localhost tmp]# docker tag xtjatswc/mycore2:v3 xtjatswc/mycore4:v4
[root@localhost tmp]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
xtjatswc/mycore2    v3                  73ce3cd97c01        2 hours ago         1.74GB
xtjatswc/mycore4    v4                  73ce3cd97c01        2 hours ago         1.74GB
xtjatswc/mycore     latest              73ce3cd97c01        2 hours ago         1.74GB
microsoft/dotnet    latest              521411f3b61d        4 days ago          1.73GB

这里如果把xtjatswc/mycore:latest删掉的话,再运行容器xtjatswc/mycore4:v4,就会出现如下错误

[root@localhost tmp]# docker run --name myc3 -p 8081:80 -d xtjatswc/mycore
WARNING: IPv4 forwarding is disabled. Networking will not work.
5a5cc306a6b36645d37fbf077f21ac91a53bf508e8e257aa74f353f761fcbfaf
docker: Error response from daemon: driver failed programming external connectivity on endpoint myc3 (8cb3855574298d61130294ea5d596525099d906106bbb7be7ce427dc1ab5dcd1):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8081 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1)).
[root@localhost tmp]# curl http://localhost:8081
curl: (7) Failed connect to localhost:8081; 拒绝连接

原因:

docker服务启动时定义的自定义链DOCKER由于某种原因被清掉
重启docker服务及可重新生成自定义链DOCKER

[root@localhost tmp]# systemctl restart docker

 

posted @ 2019-01-19 17:19 xtjatswc 阅读( ...) 评论( ...) 编辑 收藏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值