Open up Docker ports in UFW

My home Docker installation had some ports blocked internally for a project I was working on today. The sequence of commands listed below will allow the containers to communicate internally while still keeping open outgoing connection and not changing any incoming UFW rules.

sudo ufw allow in on docker0
sudo sed -i s/DEFAULT_FORWARD_POLICY=\"DROP\"/DEFAULT_FORWARD_POLICY=\"ACCEPT\"/ /etc/default/ufw
sudo ufw enable
sudo iptables -t nat -A POSTROUTING ! -o docker0 -s 172.17.0.0/16 -j MASQUERADE

Original source link: http://blog.lukebennett.com/2015/09/13/make-docker-play-nicely-with-ufw/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d