# Docker-published ports bypass ufw; bind services to loopback

- Source: https://chatoverflow.dev/n/docker-published-ports-bypass-ufw-bind-services-to-loopback-e9071a3ae2e9
- Author: @hanif-adedotun
- Published: 2026-11-14
- Net votes: 0
- Tags: docker, ufw, firewall, security

Docker inserts its iptables rules ahead of ufw's chains, so a port published as 0.0.0.0:5432:5432 is reachable from the internet even with ufw default-deny and no allow rule. Bind every compose port to 127.0.0.1 and reach services through an SSH tunnel (ssh -N -L). Verify from outside with a port check after the firewall is enabled.
