博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(ubuntu ufw)My firewall is blocking network connections from the docker container to outside
阅读量:5302 次
发布时间:2019-06-14

本文共 1234 字,大约阅读时间需要 4 分钟。

Maybe this is due to the current version, but the current answer doesn't work on my system (Docker 0.7.2 with base Ubuntu image).
The solution is explained here in the official Docker documentation.
For the lazy ones:
    edit /etc/default/ufw to change DEFAULT_FORWARD_POLICY's value to "ACCEPT",
    reload with [sudo] ufw reload.
This ensures ufw forward your traffic to the Docker's bridged network (as of my current understanding of these things...).
This fixed it for me:
 ufw allow in on docker0
Edit /etc/ufw/before.rules as follows:
In the *filter section, after the first block of required lines, add:
# docker rules to enable external network access from the container
# forward traffic accross the bridge
-A ufw-before-forward -i docker0 -j ACCEPT
-A ufw-before-forward -i testbr0 -j ACCEPT
-A ufw-before-forward -m state --state RELATED,ESTABLISHED -j ACCEPT
At the end of the file, after the line that says COMMIT, add the following section:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 172.16.42.0/8 -o eth0 -j MASQUERADE
# don't delete the 'COMMIT' line or these rules won't be processed
COMMIT
After saving the file, restart ufw with sudo ufw disable && sudo ufw enable

转载于:https://www.cnblogs.com/SZLLQ2000/p/7094274.html

你可能感兴趣的文章
docker一键安装
查看>>
leetcode Letter Combinations of a Phone Number
查看>>
Exercise 34: Accessing Elements Of Lists
查看>>
angular中的代码执行顺序和$scope.$digest();
查看>>
ALS算法 (面试准备)
查看>>
思达BI软件Style Intelligence实例教程—房地产分析
查看>>
Unity 3D 如何修改新建脚本中的 C# 默认创建的 Script 脚本格式
查看>>
Unity3D开发之NGUI点击事件穿透响应处理
查看>>
Unity 5.4 测试版本新特性---因吹丝停
查看>>
使用Scrapy爬虫框架简单爬取图片并保存本地(妹子图)
查看>>
7.5 文件操作
查看>>
DFS-hdu-2821-Pusher
查看>>
吴裕雄 Bootstrap 前端框架开发——Bootstrap 排版:地址(Address)
查看>>
吴裕雄--天生自然 JAVASCRIPT开发学习: 表单
查看>>
UITextField
查看>>
Spring事务管理的三种方式
查看>>
MyEclipse中将普通Java项目convert(转化)为Maven项目
查看>>
node js 安装.node-gyp/8.9.4 权限 无法访问
查看>>
Java_正则表达式
查看>>
Linux内核分析——第二周学习笔记
查看>>