UFW Firewall Bypassed by Published Docker Container Ports

Docker inserts `DOCKER` iptables chains ahead of UFW `INPUT` rules, exposing `-p 8080:8080` publicly.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: UFW Firewall Bypassed by Published Docker Container Ports Platform: Linux
Common Root Causes:
  • Docker inserts `DOCKER` iptables chains ahead of UFW `INPUT` rules, exposing `-p 8080:8080` publicly.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Always bind internal containers explicitly to loopback (`-p 127.0.0.1:8080:8080`).
Safe Diagnostic Command:
ss -tulpn && iptables -L DOCKER -n
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Docker inserts `DOCKER` iptables chains ahead of UFW `INPUT` rules, exposing `-p 8080:8080` publicly. Recommended diagnostic: `ss -tulpn && iptables -L DOCKER -n`. Remediation: Always bind internal containers explicitly to loopback (`-p 127.0.0.1:8080:8080`).

Worked Examples

  • Run `ss -tulpn && iptables -L DOCKER -n` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-linux-ufw-docker-port-bypass · Independently verified: 2026-11-25

Related Resources