docker -p 时iptables无效问题

栏目: 服务器 · 发布时间: 7年前

内容简介:有点标题党嫌疑,本质上是chain链顺序问题问题复现如果各位大佬跟我一样,对linux基础知识不牢固,对

有点标题党嫌疑,本质上是chain链顺序问题

问题复现

$ docker run -d -p 11111:80 nginx:alpine
$ iptables -A INPUT -p tcp --dport 11111 -j DROP
$ curl -I http://localhost:11111

HTTP/1.1 200 OK
Server: nginx/1.15.1
Date: Fri, 07 Sep 2018 09:12:59 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Fri, 06 Jul 2018 16:50:07 GMT
Connection: keep-alive
ETag: "5b3f9dbf-264"
Accept-Ranges: bytes

复制代码

如果各位大佬跟我一样,对 linux 基础知识不牢固,对 iptables 仅仅停留在 baidu 阶段,会很纠结

$ iptables -L INPUT -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:11111
复制代码

命名已经添加了 DROP ,也已经生效了,咋就是不好使呢?

通过翻查 docker 文档Docker and iptables发现,应该使用

iptables -I DOCKER-USER -p tcp --dport 11111 -j DROP 
复制代码

具体知识请自行百度


以上所述就是小编给大家介绍的《docker -p 时iptables无效问题》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Algorithms in C, Parts 1-4

Algorithms in C, Parts 1-4

Robert Sedgewick / Addison-Wesley Professional / 1997-9-27 / USD 89.99

"This is an eminently readable book which an ordinary programmer, unskilled in mathematical analysis and wary of theoretical algorithms, ought to be able to pick up and get a lot out of.." - Steve Sum......一起来看看 《Algorithms in C, Parts 1-4》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具