Docker Error Guide: 'iptables: No chain/target/match by that name' — Broken Firewall Chains
Fix 'iptables: No chain/target/match by that name' in Docker: restore the DOCKER chains a firewall flush removed by restarting the daemon cleanly.
- #docker
- #troubleshooting
- #errors
- #networking
Stuck on this Docker with AI error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
Overview
Docker programs the host firewall by inserting its own iptables chains (DOCKER, DOCKER-USER, DOCKER-ISOLATION-STAGE-1/2) and rules that NAT and forward container traffic. If those chains are missing — usually because something flushed iptables out from under the daemon — Docker cannot insert a rule and container startup fails:
Error response from daemon: driver failed programming external connectivity on endpoint web (a1b2...):
iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0.0.0.0/0 --dport 8080 -j DNAT ...:
iptables: No chain/target/match by that name.
Symptoms
- Containers with published ports fail to start after a firewall reload or
iptables -F. docker run -p ...fails while containers without published ports still start.- The error appears right after installing or reconfiguring
ufw,firewalld, or a custom iptables script. sudo iptables -t nat -L DOCKERreportsNo chain/target/match by that name.
Common Root Causes
- iptables was flushed —
iptables -F, afirewalldreload, or aufwreset wiped Docker’s chains while the daemon still expected them. - A firewall service started after Docker and reset the ruleset, removing the
DOCKERchains. - Manual iptables editing deleted or renamed a Docker-managed chain.
iptablesdisabled for Docker in the past ("iptables": false) then partially re-enabled, leaving inconsistent state.- nftables/iptables backend mismatch — the host switched backends and the chains Docker created are no longer visible to the active tool.
Diagnostic Workflow
Confirm which Docker chains exist (or do not) in the NAT and filter tables:
sudo iptables -t nat -L DOCKER -n
sudo iptables -L DOCKER -n
sudo iptables -L DOCKER-USER -n
Check the active iptables backend, since a legacy/nft mismatch hides chains:
sudo iptables --version
sudo update-alternatives --display iptables 2>/dev/null
See whether a firewall service is racing Docker:
systemctl status firewalld ufw docker --no-pager | grep -i active
Read the daemon log for the exact rule it failed to insert:
journalctl -u docker --since '15 min ago' | grep -i iptables
Example Root Cause Analysis
An operator hardened a host by adding a custom iptables -F && iptables -P INPUT DROP script that ran on boot after Docker. The next container start failed with iptables: No chain/target/match by that name. Inspecting the NAT table confirmed the damage:
$ sudo iptables -t nat -L DOCKER -n
iptables: No chain/target/match by that name.
The boot script had flushed every table, deleting Docker’s DOCKER chain, so the daemon had nowhere to add the DNAT rule for the published port. Because Docker recreates its chains on startup, the fix was simply to restart the daemon:
sudo systemctl restart docker
sudo iptables -t nat -L DOCKER -n # chain now present
To prevent recurrence, the hardening script was rewritten to insert rules into DOCKER-USER (Docker’s designated user chain) rather than flushing all tables, and ordered to run before Docker or to reload Docker afterward.
Prevention Best Practices
- Never
iptables -Fon a Docker host; put custom rules in theDOCKER-USERchain, which Docker preserves and evaluates first. - Order boot/firewall units so any tool that resets iptables runs before
docker.service, or restart Docker after it. - Prefer
firewalld/ufwintegration patterns that leave Docker’s chains intact rather than replacing the whole ruleset. - Keep a single iptables backend (legacy vs nft) consistent across the host.
- After any manual firewall change, verify with
sudo iptables -t nat -L DOCKER -nand restart Docker if the chains are gone.
Quick Command Reference
sudo iptables -t nat -L DOCKER -n # verify NAT chain exists
sudo iptables -L DOCKER-USER -n # your safe insertion point
systemctl status firewalld ufw # firewall services that may flush
sudo systemctl restart docker # recreate Docker's chains
journalctl -u docker | grep -i iptables # exact failing rule
Conclusion
iptables: No chain/target/match by that name means Docker’s firewall chains were removed after the daemon created them — almost always a flush from a firewall reload or hardening script. Restarting Docker recreates the chains and clears the error; keeping custom rules in DOCKER-USER and never flushing all tables prevents it from returning. See more networking fixes in the Docker guides.
Fixed it? Get 500 Docker with AI & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Stuck on this? Start guided troubleshooting
Open an interactive diagnostic session with this error already loaded. Work a step-by-step plan, record what each check returns, land on a root cause, and export a clean incident summary — no account needed to start.
Did this fix your issue?
Solved it a different way?
Share the fix that worked for you — reviewed, then published to help the next engineer.
That looks like it may contain a secret (key, token, password, or connection string). Please remove it — a note with a detected secret can’t be published.
Thanks — that helps. Published notes appear after a quick review.
Trending errors this week
The error guides other engineers are actually reading right now.
- 1mount: wrong fs type, bad option, bad superblock
- 2Docker 'failed to set up container networking': Fix the Bridge and IP Pool
- 3Docker 'failed to create shim task': How to Fix the containerd Runtime Error
- 4Transport endpoint is not connected
- 5modprobe: FATAL: Module not found
- 6mount: wrong fs type, bad option, bad superblock
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.