Skip to content

Switch over to xtables-legacy when nf_tables module isn't available - #465

Merged
yosifkit merged 2 commits into
docker-library:masterfrom
akerouanton:fix-nf_tables
Dec 15, 2023
Merged

yosifkit merged 2 commits into
docker-library:masterfrom
akerouanton:fix-nf_tables

Conversation

@akerouanton

Copy link
Copy Markdown
Contributor

PR #461 updated Alpine to 3.19 and made a change to load the nf_tables kernel module if needed. However, as demonstrated by #463 and #464 this might break when the host system doesn't have the nf_tables module available. In that case, we should still try to load the ip_tables module and symlink /sbin/iptables to xtables-legacy-multi.

PR docker-library#461 updated Alpine to 3.19 and made a change to load the nf_tables
kernel module if needed. However, as demonstrated by docker-library#463 and docker-library#464 this
might break when the host system doesn't have the nf_tables module
available. In that case, we should still try to load the ip_tables
module and symlink /sbin/iptables to xtables-legacy-multi.

Signed-off-by: Albin Kerouanton <[email protected]>
Comment thread dockerd-entrypoint.sh Resolved
@tianon

tianon commented Dec 15, 2023

Copy link
Copy Markdown
Member

Nice, thanks for working on this! ❤️

Modifying /sbin/xxx at runtime is definitely making me really nervous (both overwriting files installed by a package and modifying /sbin/ in general), so I think I'd prefer if we create a directory of symlinks in the Dockerfile that the entrypoint can then use PATH tricks to activate instead. Given we're already at the end of your day (and the severity of the breaking change), I hope you don't mind me taking over instead of describing in more detail and requesting changes? 😇

@tianon
tianon force-pushed the fix-nf_tables branch 2 times, most recently from 6a47f67 to e360b4d Compare December 15, 2023 18:18
Comment thread dockerd-entrypoint.sh
if ! modprobe nf_tables; then
modprobe ip_tables || :
# see https://github.com/docker-library/docker/issues/463 (and the dind Dockerfile where this directory is set up)
export PATH="/usr/local/sbin/.iptables-legacy:$PATH"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice side benefit of this method is that users having trouble with it misfiring (somehow) is that they can just hide this directory somehow like bind-mounting /dev/null on top of it, and the container will happily continue using the default Alpine-provided iptables symlink. 👍

@tianon

tianon commented Dec 15, 2023

Copy link
Copy Markdown
Member
/ # ls /usr/local/
bin    lib    share

grumble grumble grumble

…ed symlink farm instead of symlinking over package-provided files in /sbin/ at runtime
@yosifkit
yosifkit merged commit 7ac5702 into docker-library:master Dec 15, 2023
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Dec 15, 2023
Changes:

- docker-library/docker@7ac5702: Switch over to xtables-legacy when nf_tables module isn't available (docker-library/docker#465)
@tianon

tianon commented Dec 18, 2023

Copy link
Copy Markdown
Member

Follow-up in #468 👀

@akerouanton
akerouanton deleted the fix-nf_tables branch June 7, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dockerd fails to start - RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1

4 participants