brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ufw does not filter Docker ports, so publish them on 127.0.0.1

Ufw
~/tips/tip-ufw-docker-published-ports

docker run -d -p 127.0.0.1:8080:80 nginx

Explains why ufw misses published container ports and how to avoid it.

A common trap is to read an empty ufw status as proof that a container port is closed. Docker writes its own iptables rules, and traffic to published ports skips the ufw chains.

docker run -d -p 127.0.0.1:8080:80 nginx
sudo iptables -L DOCKER-USER -n

A plain -p 8080:80 binds on all interfaces and is reachable from outside no matter what ufw says. Binding to 127.0.0.1 keeps it local, and a reverse proxy on the same host can still reach it. For rules that apply to published ports, add them to the DOCKER-USER chain, which Docker evaluates first. Docker documents this in its packet filtering and firewalls page.

Further reading: Docker packet filtering and firewalls

More Ufw tips sudo ufw app update all sudo ufw show raw sudo ufw allow to 10.0.0.1 proto esp sudo ufw allow to 224.0.0.0/24 from 10.0.0.1 proto vrrp sudo ufw show listening All Ufw tips (32) All topics

Link