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

(ubuntu ufw)My firewall is blocking network connections from the docker container to outside的更多相关文章

  1. blocking network call

    [blocking network call] 阻塞的网络调用: 1.gethostbyname(): does not return until it has succeeded or failed ...

  2. ORA-12528: TNS:listener: all appropriate instances are blocking new connections

    Oracle问题:ORA-12528: TNS: 监听程序: 所有适用例程都无法建立新连接 问题原始描述: ORA-12528: TNS:listener: all appropriate insta ...

  3. ubuntu ufw 配置

    ubuntu ufw 配置 Ubuntu 18.04 LTS 系统中已经默认附带了 UFW 工具,如果您的系统中没有安装,可以在「终端」中执行如下命令进行安装: 1 sudo apt install ...

  4. Docker container network configuration

    http://xmodulo.com/networking-between-docker-containers.html How to set up networking between Docker ...

  5. tomcat7 fail to start inside Ubuntu Docker container

    The tomcat startup script needs some special privileges. Concrete it needs to check all running proc ...

  6. Linux之防火墙管理篇[Ubuntu:ufw]

    前言 由于近期,腾讯云服务器就要到期了,学生优惠即将失效了,所以准备将数据库和项目迁移到vultr上.然而,在使用nivicat连接mysql数据库的过程中,却屡次出现:Can't connect t ...

  7. ubuntu ufw防火墙软件的配置入门

    顺便,一条龙作完安全吧. ufw的使用,是比iptables简单.但只能作简单的事儿,更改简单的netfilter里的iptable里的记录.难点的,可能还是得iptables原生命令. 自打2.4版 ...

  8. ubuntu ufw防火墙

    由于LInux原始的防火墙工具iptables过于繁琐,所以ubuntu默认提供了一个基于iptable之上的防火墙工具ufw. ubuntu 9.10默认的便是UFW防火墙,它已经支持界面操作了.在 ...

  9. 【Linux】ubuntu或linux网卡配置/etc/network/interfaces

    转自:http://gfrog.net/2008/01/config-file-in-debian-interfaces-1/   青蛙准备写一个系列文章,介绍一些Debian/Ubuntu里面常用的 ...

随机推荐

  1. _mysql_exceptions.ProgrammingError:(2014, "commands out of sync; you can't run this command now")

    今天,测试dashboard上的一些graph, 发现,当多个graph同时向后台请求数据(异步)的时候, 出现了上述错误.而且,三个bug交替出现,另外两个bug分别是:python stop re ...

  2. nginx重写规则配置

    https://segmentfault.com/a/1190000002797606 location正则写法 一个示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符 ...

  3. Java------遍历Map<k,v>的方法

    1. public class MapAction extends ActionSupport{ private Map<String, User> map = new HashMap&l ...

  4. 【RF库Collections测试】Get Index From List

    Name:Get Index From ListSource:Collections <test library>Arguments:[ list_ | value | start=0 | ...

  5. 批处理bat文件dos命令复制文件

    ::将“C:\Users\ZZ\Desktop\快捷处理\我我我哦我”路径下的文件复制到“C:\Temp\我我我哦我”路径下::/S表示“复制目录和子目录,除了空的.”::/E表示“复制目录和子目录, ...

  6. 使用jq的ajax实现对xml文件的读取

    之前一直在用json来传递数据,但是xml也是不可缺少的,于是开始了xml的征程.xml的一些属性啊之类的在菜鸟教程上列举的已经很详细了,但是却没有前段部分的获取教程,查询资料,遂懂: index.x ...

  7. Linux命令之type - 显示命令的类型

    用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令 ...

  8. Swift-'as?','as'用法

    何时使用 'as?'和'as' 让我们来继续为我们假象的UIKit应用写点代码.假设你需要出场(展示)一个新的modal view controller到手机的屏幕上(比如通过使用presentVie ...

  9. GROW

    经理今天介绍了一下,GROW,就给他放上来了:   有一个辅导的方法 叫做 GROW (G:goal:R:reality:O:option:W:will)这个辅导方法是这样的,客观地给自己或者别人提问 ...

  10. Date Json格式转换Date格式

    CreateTime=\/Date(1458722493663+0800)\/ var CreateTime="/Date(1458722493663+0800)/";var st ...