UFW After rules for Docker on Ubuntu
Add to /etc/ufw/after.rules the following rules. And then restart the UFW service: /etc/init.d/ufw restart
# BEGIN UFW AND DOCKER
*filter
:ufw-user-forward - [0:0]
:ufw-docker-logging-deny - [0:0]
:DOCKER-USER - [0:0]
-A DOCKER-USER -j ufw-user-forward
-A DOCKER-USER -j RETURN -s 172.17.0.0/