Before I add a firewall rule, I want to know which services listen at all.
sudo ss -tulpn
sudo ss -tlnp | grep -v -e '127.0.0.1' -e '\[::1\]'
-t and -u select TCP and UDP, -l only listening sockets, -n keeps numbers instead of names and -p shows the process. The second line drops lines containing 127.0.0.1 or [::1], which leaves most services that other machines can reach. Other loopback addresses such as 127.0.0.53 still show up.
Without sudo the process column stays empty for other users’ programs. Ports published by Docker often show up as docker-proxy. Docker publishes them through its own iptables rules, which ufw does not filter, so check them here instead of trusting the firewall status.
Further reading: ss manual page