If you see your Docker container ports got exposed and bypassed all UFW rules, that is normal because Docker will manipulate iptables when creating container. Docker in default will work with iptables nicely without user creating complicated iptables rules. If you don’t want Docker creating iptables rules or you are using UFW, you need to propertly configure them to make then work nicely together.