code · Nov 12, 2026

Docker port reachable despite UFW

Docker container port is reachable from the internet despite UFW denying incoming and no port forwarding. How to block it without disabling iptables

Part of Docker Compose: startup, networking and configuration

Symptom: `ufw status` is active with default deny incoming, yet a container started with `-p 8080:8080` answers from the internet. Cause: Docker publishes ports by writing DNAT rules into the nat table and its own DOCKER chains into filter. Forwarded traffic is accepted there before UFW's rules ever see it. Scope: this applies to Docker with the iptables backend, the default on most distributions. With the nftables backend there is no DOCKER-USER chain and the rule below matches nothing. Fix, never set `"iptables": false`, that breaks container networking. Restrict forwarded traffic in DOCKER-USER, which Docker evaluates before its own rules. Add above the final COMMIT of the `*filter` block in `/etc/ufw/after.rules`: ``` :DOCKER-USER - [0:0] -A DOCKER-USER -i eth0 -p tcp -m conntrack --ctorigdstport 8080 --ctdir ORIGINAL -j DROP ``` then `ufw reload` while Docker is running, and replace `eth0` with the external interface from `ip -br a`. The rule covers IPv4 TCP only. A service published on `::` stays reachable over IPv6: add the same line via `ip6tables` to `/etc/ufw/after6.rules`, and use `-p udp` for UDP. Check both chains with `iptables -S DOCKER-USER` and `ip6tables -S DOCKER-USER`. Verify from a host outside the network: `curl -m 5 http://<public-host>:8080` must time out, while containers on the same Docker network still reach the service.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json