The Docker daemon failed to manage iptables rules because it couldn’t find specific chains or targets it expected to exist.
This usually means something else is already managing iptables, and Docker’s assumptions are being violated.
Cause 1: iptables-persistent is actively managing rules.
-
Diagnosis: Check if
iptables-persistentis running and has rules saved.sudo systemctl status netfilter-persistent sudo iptables-save > ~/iptables-save.bakIf
netfilter-persistentis active andiptables-saveoutputs rules (not just empty*filterlines), this is likely your culprit. -
Fix: Temporarily stop
iptables-persistentand let Docker manage iptables.sudo systemctl stop netfilter-persistent sudo systemctl disable netfilter-persistent sudo systemctl stop docker sudo systemctl start dockerThis allows Docker to create its
DOCKERandDOCKER-ISOLATION-STAGE-1chains without conflict. -
Why it works:
iptables-persistentsaves and loads rules on boot, effectively "owning" the iptables state. Stopping it relinquishes control, allowing Docker to initialize its network components cleanly.
Cause 2: ufw (Uncomplicated Firewall) is enabled and managing iptables.
-
Diagnosis: Check if
ufwis active.sudo ufw statusIf
ufwisactive, it’s likely interfering. -
Fix: Disable
ufwand allow Docker to manage iptables.sudo ufw disable sudo systemctl restart dockerYou’ll need to re-implement any specific
ufwrules you need directly in Docker or via other firewall management tools. -
Why it works:
ufwis a frontend foriptablesand manages its own chains. Docker’s attempt to create its standard chains will fail ifufwhas already established its own structure and rules.
Cause 3: Manual iptables rules have been added that conflict with Docker’s expected chains.
-
Diagnosis: Inspect your current iptables rules.
sudo iptables -L -n -vLook for any custom chains or rules that might overlap with Docker’s naming conventions (e.g.,
DOCKER,DOCKER-USER,DOCKER-ISOLATION-STAGE-1). -
Fix: Remove conflicting custom rules or chains. For example, if you find a custom
DOCKERchain, you might remove it:sudo iptables -t nat -F DOCKER # If it's in the NAT table sudo iptables -t filter -F DOCKER # If it's in the filter table sudo iptables -X DOCKER sudo systemctl restart dockerBe cautious when removing rules; back them up first with
iptables-save. -
Why it works: Docker expects to create and control specific chains for its networking. If these chains already exist with different configurations or are deleted entirely due to manual intervention, Docker cannot proceed.
Cause 4: The iptables service is not running or is misconfigured.
-
Diagnosis: Check the status of the
iptablesservice.sudo systemctl status iptablesAlso, check if the
netfilter-persistentservice (which often handlesiptablesloading) is running.sudo systemctl status netfilter-persistent -
Fix: Ensure the
iptablesservice is enabled and started.sudo systemctl enable iptables sudo systemctl start iptables # If using netfilter-persistent, ensure it's also running sudo systemctl enable netfilter-persistent sudo systemctl start netfilter-persistent sudo systemctl restart docker -
Why it works: Docker relies on the underlying
iptablesbinary and its associated services to manage firewall rules. If these services are not active, Docker cannot execute the necessaryiptablescommands.
Cause 5: Docker’s network configuration is corrupted or not initialized.
-
Diagnosis: Docker’s network configuration is stored in
/var/lib/docker/network/. Check for recent modifications or signs of corruption.ls -l /var/lib/docker/network/ -
Fix: Remove Docker’s network configuration and let it rebuild.
sudo systemctl stop docker sudo rm -rf /var/lib/docker/network/* sudo systemctl start dockerWarning: This will remove all custom Docker networks. You will need to recreate them.
-
Why it works: Docker uses this directory to store definitions for its networks, including the iptables rules associated with them. Deleting and recreating allows Docker to re-initialize these configurations from scratch.
Cause 6: Kernel modules for netfilter/iptables are not loaded.
-
Diagnosis: Check if the relevant kernel modules are loaded.
lsmod | grep ip_tables lsmod | grep x_tables lsmod | grep nf_natIf these are missing,
iptablescommands will fail. -
Fix: Load the necessary modules manually.
sudo modprobe ip_tables sudo modprobe x_tables sudo modprobe nf_nat sudo systemctl restart dockerIf these modules are not available, your kernel might not be compiled with netfilter support, which is highly unusual for standard Linux distributions.
-
Why it works: These kernel modules provide the core functionality for packet filtering and Network Address Translation (NAT) that
iptablesuses. Without them, theiptablescommand-line utility has no backend to interact with.
After resolving the primary iptables issue, you might encounter a "failed to load bridge local traffic filter" error if Docker’s internal bridge networking isn’t fully initialized.