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. php如何解决多线程同时读写一个文件的问题

    <?php header("content-type:text/html;charset=utf-8"); $fp = fopen("lock.txt", ...

  2. Unity3d + PureMVC框架搭建

    0.流程:LoginView-SendNotification()---->LoginCommand--Execute()--->调用proxy中的函数操作模型数据--LoginProxy ...

  3. Fast-RCNN

    后面框架回归和分类都放到了神经网络里 测试速度提升100倍 训练10

  4. Android 6.0启动过程具体解析

    在之前的一篇文章中.从概念上学习了Andoird系统的启动过程.Android系统启动过程学习 而在这篇文章中,我们将从代码角度细致学习Android系统的启动过程,同一时候,学习Android启动过 ...

  5. 超全面的JavaWeb笔记day01<HTML等>

    1.html简介 - html的操作思想(*****) 2.文字标签和注释标签 3.标题标签.水平线标签和特殊字符 4.列表标签 5.图像标签(********) 6.路径介绍(相对路径*****) ...

  6. osgEarth使用没有DX的Triton库Triton-MT-DLL-NODX.lib

    将Triton-MT-DLL修改为Triton-MT-DLL-NODX

  7. laravel框架容器管理的一些要点

    本文面向php语言的laravel框架的用户,介绍一些laravel框架里面容器管理方面的使用要点.文章很长,但是内容应该很有用,希望有需要的朋友能看到.php经验有限,不到位的地方,欢迎帮忙指正. ...

  8. linux系统usb挂载

    本次例程的环境是在FC6下,通过终端操作的. 注意要挂载U盘需要有管理员的权限. 切换成管理员,输入: su root 然后输入管理员密码,进行密码认证: 成功后,先在 /mnt 下建立一个名叫USB ...

  9. 使用类/结构体时关于ZeroMomery用法错误

    今天同事在写了如下结构体: typedef struct _tagInfo { std::list<int> lst; std::vector<int> nVec; } INF ...

  10. 使用jQuery操作元素属性

    在jQuery中,提供了attr函数来操作元素属性,具体如下: 函数名 说明 例子 attr(name) 取得第一个匹配元素的属性值. $("input").attr(" ...