If you’re running Docker Compose on a Rocky Linux or RHEL-based server and encounter the following error, it may be caused by a kernel module or iptables
configuration issue:
|
|
Cause
By default, Docker uses the DOCKER
chain in iptables
to configure NAT rules when using the bridge
network driver. This error may occur if any of the following conditions are met:
- The
br_netfilter
orbridge
kernel module is not loaded - A conflict exists between
iptables
andnftables
- A container is launched before the network is created
- The system is using the
iptables-nft
backend
Solution
1. Load Required Kernel Modules
|
|
To verify:
|
|
To load them automatically at boot:
|
|
2. Switch to iptables-legacy Backend
Docker still prefers iptables-legacy
. If your system is using iptables-nft
, switch using the following command:
|
|
Sample output:
|
|
Repeat for the following:
|
|
3. Restart Docker
Changes to the iptables
backend or kernel modules require Docker to be restarted:
|
|
If the Issue Persists
- If
firewalld
ornftables
is active, they may interfere with Docker’siptables
rules. Consider disablingfirewalld
or configuring it to work alongsideiptables
. - On KVM-based VMs with bridged networking, the host kernel might restrict module loading. Double-check module availability and system policies.
Conclusion
Most Docker Compose network errors like this stem from iptables
misconfigurations or missing kernel modules. Following the above steps should resolve the issue in most cases. For RHEL and Rocky Linux systems in particular, switching to iptables-legacy
is often the key fix.