[Bug] Switching Container Port Guard backend to nftables causes dockerd to crash on startup when net.ipv4.ip_forward = 0 without pre-check or remediation
Author: WAORCreated Sep 14, 2026Updated Sep 17, 2026
Labelstype: bugstatus: dev-completestatus: ready-for-release
Contact Information
No response
1Panel Version
2.3.0
Problem Description
A. Divergent Behavioral Difference: iptables vs. nftables in Docker
There is a fundamental difference in how Docker (libnetwork) handles net.ipv4.ip_forward == 0 between firewall backends:
- Legacy
iptablesBackend (Silent In-Memory Remediation):- Under the legacy
iptablesdriver, ifnet.ipv4.ip_forwardis0, Docker emits a soft log warning (WARNING: IPv4 forwarding is disabled. Networking will not work.), but it automatically and silently modifies the kernel runtime memory/proc/sys/net/ipv4/ip_forwardto1. - Because Docker did this behind the scenes, many servers (even with
#net.ipv4.ip_forward=1commented out in/etc/sysctl.conf) ran fine without administrators ever realizing it.
- Under the legacy
- Modern
nftablesBackend (Strict Assertion & Immediate Crash):- In Docker v26+ with
"firewall-backend": "nftables", this silent in-memory auto-remediation logic was removed. - Instead, Docker enforces a strict assertion. If
net.ipv4.ip_forward == 0,dockerdtreats it as an unrecoverable failure and aborts startup:dockerd[...]: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: ... (exit status 1) dockerd[...]: failed to start daemon: Error initializing network controller: IPv4 forwarding is disabled systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
- In Docker v26+ with
B. Architectural Defect in 1Panel
In agent/app/service/firewall_docker.go and firewall_setting.go:
- 1Panel provides a one-click UI toggle to switch Docker's backend to
nftables, but it assumesnet.ipv4.ip_forward = 1is already persistently enabled at the host level. - When 1Panel applies
"firewall-backend": "nftables":- It does not inspect
/proc/sys/net/ipv4/ip_forward. - It does not persist
net.ipv4.ip_forward = 1to/etc/sysctl.d/.
- It does not inspect
- As a result, any host relying on clean Ubuntu defaults or using kernel hardening scripts (which explicitly maintain
net.ipv4.ip_forward = 0) immediately suffers a total Docker collapse, and 1Panel loses connection to/var/run/docker.sock.
Steps to Reproduce
- On a Linux server (e.g., Ubuntu 24.04 / 26.04), ensure IP forwarding is disabled (
net.ipv4.ip_forward = 0), which is the factory default on clean Ubuntu/Debian installations and standard CIS/security hardening templates:sysctl -w net.ipv4.ip_forward=0 - Log in to the 1Panel web console.
- Navigate to System -> Firewall -> Settings.
- In the Container Port Guard section, switch the Docker firewall backend to nftables and click apply/initialize.
- 1Panel adds
"firewall-backend": "nftables"to/etc/docker/daemon.jsonand restarts Docker. - Check Docker daemon status:
systemctl status docker journalctl -u docker -n 50 --no-pager - Result:
dockerdcrashes immediately on startup with exit status 1 (failed to start daemon: Error initializing network controller: IPv4 forwarding is disabled), bringing down all running containers across the host.
The expected correct result
- Pre-flight Kernel Parameter Check: Before applying
"firewall-backend": "nftables"to/etc/docker/daemon.json, 1Panel should check/proc/sys/net/ipv4/ip_forward. - Automatic Remediation & Persistence: If
net.ipv4.ip_forward = 0, 1Panel should either:- Alert the administrator that
net.ipv4.ip_forward = 1is strictly mandatory under Docker's newnftablesdriver; OR - Automatically persist
net.ipv4.ip_forward = 1into/etc/sysctl.d/99-1panel.confand applysysctl --systembefore restarting Docker.
- Alert the administrator that
- Failure Health Check & Safe Rollback: If
dockerdfails to start within 10–15 seconds after switching the backend, 1Panel should automatically revert/etc/docker/daemon.jsonback to"firewall-backend": "iptables"and restore the containers to prevent production outages.
Related log output
Additional Information
No response
Source: 1Panel-dev/1Panel