The manual iptables configuration and isolation rules (DOCKER-ISOLATION) described in this document are valid up to Docker CE version 27.
From version 28 and later (29, etc.), Docker has migrated to the NFTables backend by default.
apt install docker-ce=5:27.5.1-1~debian.12~bookworm
apt install docker-ce-cli=5:27.5.1-1~debian.12~bookworm
apt install docker-ce-rootless-extras=5:27.5.1-1~debian.12~bookwormdocker network create --driver bridge container-net
docker network create --driver bridge --subnet "192.168.33.0/24" --gateway "192.168.33.10" internal
docker network create --driver bridge --subnet "172.20.46.0/24" --gateway "172.20.46.254" external# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eno1
iface eno1 inet dhcp
post-up /etc/iptables-single-bridge.sh
#post-up /etc/iptables-multi-bridge.sh
chmod a+x /etc/iptables-single-bridge.sh
chmod a+x /etc/iptables-multi-bridge.shiptables -L FORWARD -v -nDefault Docker Rules:
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
43060 26M DOCKER-USER 0 -- * * 0.0.0.0/0 0.0.0.0/0
43060 26M DOCKER-ISOLATION-STAGE-1 0 -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT 0 -- * docker0 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
0 0 DOCKER 0 -- * docker0 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT 0 -- docker0 !docker0 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT 0 -- docker0 docker0 0.0.0.0/0 0.0.0.0/0
26303 23M ACCEPT 0 -- * br-caed2ff56793 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
130 49312 DOCKER 0 -- * br-caed2ff56793 0.0.0.0/0 0.0.0.0/0
16627 2975K ACCEPT 0 -- br-caed2ff56793 !br-caed2ff56793 0.0.0.0/0 0.0.0.0/0
129 49264 ACCEPT 0 -- br-caed2ff56793 br-caed2ff56793 0.0.0.0/0 0.0.0.0/0
Added Docker Rules:
0 0 ACCEPT 0 -- br-caed2ff56793 eno1 0.0.0.0/0 0.0.0.0/0
109 7000 ACCEPT 0 -- eno1 br-caed2ff56793 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT 0 -- eno1 br-caed2ff56793 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
Network 192.168.33.0/24
Distance: 1
Value: 172.20.1.66 (IP Address of eno1)
docker network create myNetwork
docker network connect myNetwork internal
docker network connect myNetwork external
iptables --flush DOCKER-ISOLATION
Check bridge name of network (example):
iptables -I DOCKER-ISOLATION-STAGE-2 -o internal -i external -j ACCEPT
iptables -I DOCKER-ISOLATION-STAGE-2 -o external -i internal -j ACCEPT