(Ubuntu UFW) My Firewall is blocking network connections from the Docker container to outside

Source: Internet
Author: User





Maybe this was 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 this 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 sections, 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 "says COMMIT, add the following section:

*nat
:P ostrouting 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.