Skip to content

Commit

Permalink
Add DOCKER_IPTABLES_LEGACY for letting users explicitly pick `iptab…
Browse files Browse the repository at this point in the history
…les-legacy`

via `--env DOCKER_IPTABLES_LEGACY=1`
  • Loading branch information
tianon committed Jan 4, 2024
1 parent d5d05eb commit eb4c40e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
11 changes: 10 additions & 1 deletion 24/dind/dockerd-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion 25-rc/dind/dockerd-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion dockerd-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,15 @@ if [ "$1" = 'dockerd' ]; then
set -- docker-init -- "$@"

iptablesLegacy=
if (
if [ -n "${DOCKER_IPTABLES_LEGACY+x}" ]; then
# let users choose explicitly to legacy or not to legacy
iptablesLegacy="$DOCKER_IPTABLES_LEGACY"
if [ -n "$iptablesLegacy" ]; then
modprobe ip_tables || :
else
modprobe nf_tables || :
fi
elif (
# https://git.netfilter.org/iptables/tree/iptables/nft-shared.c?id=f5cf76626d95d2c491a80288bccc160c53b44e88#n420
# https:/docker-library/docker/pull/468#discussion_r1442131459
for f in /proc/net/ip_tables_names /proc/net/ip6_tables_names /proc/net/arp_tables_names; do
Expand Down Expand Up @@ -174,6 +182,7 @@ if [ "$1" = 'dockerd' ]; then
# see https:/docker-library/docker/issues/463 (and the dind Dockerfile where this directory is set up)
export PATH="/usr/local/sbin/.iptables-legacy:$PATH"
fi
iptables --version # so users can see whether it's legacy or not

uid="$(id -u)"
if [ "$uid" != '0' ]; then
Expand Down

0 comments on commit eb4c40e

Please sign in to comment.