[docker-in-docker] - Move the iptables switching logic in the docker-init script and isolated tests for specific cases#1666
Conversation
|
LGTM @ I don't see anything wrong with 7360873 if the tests pass There are cases where If you can think of one then it might be worth checking for iptables nat - I cant remember what case I ran into since it was ~ a month ago, entirely possible that I was doing something silly. Example: iptable-nat not available. |
Hi @SrzStephen Thank you for the review. Let me have a look for that scenario. |
| "default": false, | ||
| "description": "Disable ip6tables (this option is only applicable for Docker versions 27 and greater)" | ||
| }, | ||
| "iptablesSwitchAtRuntime": { |
There was a problem hiding this comment.
Probably the only thing I'd try to make a case for, but I'm not overly familiar with this repos general policy here so if it tends to more conservative then that's ok:
If you're moving to a v4 release it might be worth making this a default: true since you're already cutting a major rev.
Reason: The only time it matters what iptables is present is at runtime so it's probably the correct approach, someone can always opt into the old behaviour if they wish (by setting it to false) but you'll probably see some "why doesn't docker run" issues similar to #1659.
There was a problem hiding this comment.
Makes sense. I would much rather put it back to version 3 as the flag could help doing this seamlessly.
There was a problem hiding this comment.
I'm wondering since 3.0.0 and 3.0.1 break on Ubuntu 24.04 devcontainer base images on a nUbuntu 26.04 host anyway and my testing indicates that the 3.1.0/4.0.0 feature works also on an Ubuntu 22.04 why not considering this a fix with a new compatible feature with the default of iptablesSwitchAtRuntime:true? This makes the 3.x feature working; are there any side effects of the iptablesSwitchAtRuntime?
Summary
Fixes #1659 and fixes #1662.
This PR updates the
docker-in-dockerfeature to support selecting theiptablesbackend at container runtime instead of only during image build. This is needed for hosts where the correct backend depends on the host kernel state at runtime, such as systems where theip_tableskernel module is not loaded andiptables-legacyexists but does not work.It also updates Docker Compose handling so
dockerDashComposeVersionsupportslatestand uses it as the default.Changes
docker-in-dockeroption:iptablesSwitchAtRuntime:falseiptablesalternatives selection logic intodocker-init.shso it runs beforedockerdstarts.iptablesSwitchAtRuntimeis not enabled.iptables-legacyonly when the legacy backend is actually available through the host kernel.iptables-nftwhen legacy support is unavailable.latestas a validdockerDashComposeVersionvalue.dockerDashComposeVersionfromv2tolatest.install.sh,devcontainer-feature.json, and the README option table accordingly.docker-in-dockerREADME with the new/updated options.docker-in-dockerfeature version to3.1.0.Test Coverage
Adds isolated test scenarios for:
ip_tablesloaded.ip_tablesloaded.ip_tablesloaded.ip_tablesloaded.iptablesSwitchAtRuntime=true.latestbehavior with Moby enabled.latestbehavior with Moby disabled.Also updates CI to isolate the iptables-specific scenarios so they do not interfere with the standard
docker-in-dockerscenario test matrix.Validation
The new tests verify that:
docker-init.shcontains the runtime switching block only wheniptablesSwitchAtRuntime=true.iptablesalternative is eitheriptables-legacyoriptables-nftas appropriate.iptablescommands work.dockerdstarts successfully.docker psworks inside the dev container.docker compose versionreturns a valid version whendockerDashComposeVersion=latest.docker-compose --versionreturns a valid version whendockerDashComposeVersion=latest./usr/local/bin/docker-composeis installed for thelatestDocker Compose scenario.