The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall.
Create or edit /etc/docker/daemon.json
:
{
"iptables": false,
"dns": ["213.186.33.99"]
}
Restart Docker engine :
sudo systemctl restart docker
/etc/default/ufw
:DEFAULT_FORWARD_POLICY
value to ACCEPT
/etc/ufw/before.rules
:Add the following content BEFORE *filter
:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING ! -o docker0 -j MASQUERADE
COMMIT
ufw allow from 172.17.0.0/16
SSH example :
sudo ufw allow ssh
sudo ufw reload
Warning : Check UFW rules before apply. You can lost connection on critical services (SSH, Web etc...)