diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json index b6f7d1611..805eb4dc9 100644 --- a/src/docker-in-docker/devcontainer-feature.json +++ b/src/docker-in-docker/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "docker-in-docker", - "version": "4.1.3", + "version": "4.1.4", "name": "Docker (Docker-in-Docker)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-in-docker", "description": "Create child containers *inside* a container, independent from the host's docker instance. Installs Docker extension in the container along with needed CLIs.", diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index 61f94f77a..aa5e7786b 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -1008,7 +1008,7 @@ if [ "${IPTABLES_SWITCH_AT_RUNTIME}" = "true" ] && [ "${ADJUSTED_ID}" = "debian" # and would defeat hosts/scenarios where the module is intentionally absent # such as the newer kernels which leaves out ip_tables legacy.) if type iptables-legacy > /dev/null 2>&1 \ - && { grep -qE '^(ip_tables)\b' /proc/modules \ + && { grep -qE '^(ip_tables)\b' /proc/modules 2>/dev/null \ || [ -d /sys/module/ip_tables ]; } \ && update-alternatives --list iptables 2>/dev/null | grep -q '/usr/sbin/iptables-legacy'; then sudo_if update-alternatives --set iptables /usr/sbin/iptables-legacy || true diff --git a/test/docker-in-docker/docker_iptables_switch_at_runtime.sh b/test/docker-in-docker/docker_iptables_switch_at_runtime.sh index 152a4ec98..25ad2296e 100644 --- a/test/docker-in-docker/docker_iptables_switch_at_runtime.sh +++ b/test/docker-in-docker/docker_iptables_switch_at_runtime.sh @@ -11,6 +11,7 @@ check "init-script-exists" bash -c "test -f /usr/local/share/docker-init.sh" check "runtime-iptables-block-present" bash -c "grep -q 'update-alternatives --set iptables' /usr/local/share/docker-init.sh" check "runtime-iptables-block-has-legacy-branch" bash -c "grep -q '/usr/sbin/iptables-legacy' /usr/local/share/docker-init.sh" check "runtime-iptables-block-has-nft-branch" bash -c "grep -q '/usr/sbin/iptables-nft' /usr/local/share/docker-init.sh" +check "runtime-iptables-proc-modules-check-is-quiet" bash -c "grep -q '/proc/modules 2>/dev/null' /usr/local/share/docker-init.sh" # The runtime block runs as part of docker-init.sh (the feature's entrypoint), # so by the time these tests execute the alternative must already be set. diff --git a/test/docker-in-docker/docker_iptables_switch_at_runtime_non_root.sh b/test/docker-in-docker/docker_iptables_switch_at_runtime_non_root.sh index 7a957b55d..cc1d2e7ae 100644 --- a/test/docker-in-docker/docker_iptables_switch_at_runtime_non_root.sh +++ b/test/docker-in-docker/docker_iptables_switch_at_runtime_non_root.sh @@ -6,7 +6,11 @@ set -e source dev-container-features-test-lib check "entrypoint runs as codespace" bash -c "test \"$(id -un)\" = codespace" -check "iptables uses legacy backend" bash -c "iptables --version | grep -q '(legacy)'" +check "iptables version" iptables --version +# The build-time switch should have set /etc/alternatives/iptables to one of the +# known backends. With the ip_tables module loaded on the host, legacy is preferred. +check "iptables-alternative-set" bash -c "readlink /etc/alternatives/iptables | grep -E 'iptables-(legacy|nft)$'" +check "iptables works" sudo iptables -L # Report result reportResults \ No newline at end of file