

Been a minute since I touched iptables, but IIRC, not quite that simple.
You’d want to allow outbound connections to destination ports of 80/443/22 and then also allow responses from any established connection (because the server replies won’t likely be going back to your port 80/443/22 as their dest). Unless you’re running dns over https across your whole system, you’ll need to allow that too.
Nothing against doing things the hard way, but you might like OpenStitch if you’re looking to control traffic in a practical manner.






PSA for those who haven’t read the docker docs in detail: If you run docker with UFW or any other iptables based firewall, it will often overwrite and break your firewall rules.
Many people running containers on public hosts get burned by this, because they’re expecting their firewall to block outside traffic from hitting the container.
Firewalld is a solid alternative that does not suffer from the same failure model; highly recommend.