我是靠谱客的博主 繁荣可乐,最近开发中收集的这篇文章主要介绍(ubuntu ufw)My firewall is blocking network connections from the docker container to outside,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述





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

最后

以上就是繁荣可乐为你收集整理的(ubuntu ufw)My firewall is blocking network connections from the docker container to outside的全部内容,希望文章能够帮你解决(ubuntu ufw)My firewall is blocking network connections from the docker container to outside所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部