Skip to content

fix: docker-in-docker on Ubuntu 26.04 — verify iptables-legacy works before switching - #1637

Merged
Kaniska (v-Kaniska244) merged 10 commits into
mainfrom
copilot/fix-docker-in-docker-ubuntu-26-04
May 13, 2026
Merged

Kaniska (v-Kaniska244) merged 10 commits into
mainfrom
copilot/fix-docker-in-docker-ubuntu-26-04

Conversation

Copilot AI commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Docker daemon fails to start on Ubuntu 26.04 (resolute) because the kernel no longer supports legacy iptables NAT tables. The install script was unconditionally switching to iptables-legacy whenever the binary existed, regardless of kernel support.

Changes

  • iptables fallback logic — Verify iptables-legacy actually works (-nL probe) before switching to it; fall back to iptables-nft if legacy fails:
    if type iptables-legacy > /dev/null 2>&1 && iptables-legacy -nL > /dev/null 2>&1; then
        update-alternatives --set iptables /usr/sbin/iptables-legacy
        update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
    elif type iptables-nft > /dev/null 2>&1 && iptables-nft -nL > /dev/null 2>&1; then
        update-alternatives --set iptables /usr/sbin/iptables-nft
        update-alternatives --set ip6tables /usr/sbin/ip6tables-nft
    fi

Note:- The -nL probe doesn’t work during the docker container build when the installation script executes. The probe works only in the runtime when container is live. Changed the above as below.

# Swap to legacy iptables for compatibility (Debian only)
if [ "${ADJUSTED_ID}" = "debian" ]; then
    # On distros where legacy iptables is no longer kernel-supported (e.g. Ubuntu 26.04 / resolute),
    # prefer iptables-nft. Otherwise prefer legacy for backward compatibility.
    use_nft=false
    case "${VERSION_CODENAME}" in
        resolute) use_nft=true ;;
    esac

    if [ "${use_nft}" = "true" ] && type iptables-nft > /dev/null 2>&1; then
        update-alternatives --set iptables /usr/sbin/iptables-nft || true
        update-alternatives --set ip6tables /usr/sbin/ip6tables-nft || true
    elif type iptables-legacy > /dev/null 2>&1; then
        update-alternatives --set iptables /usr/sbin/iptables-legacy || true
        update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true
    elif type iptables-nft > /dev/null 2>&1; then
        update-alternatives --set iptables /usr/sbin/iptables-nft || true
        update-alternatives --set ip6tables /usr/sbin/ip6tables-nft || true
    fi
fi
  • Add resolute codename to DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES and DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES
  • Add test scenario docker_build_ubuntu_resolute targeting ubuntu:resolute with moby: false (moby is not yet supported on Ubuntu resolute)
  • Minor version bump from 2.16.1 → 2.17.0 in devcontainer-feature.json

Copilot AI changed the title [WIP] Fix docker-in-docker feature on Ubuntu 26.04 fix: docker-in-docker on Ubuntu 26.04 — verify iptables-legacy works before switching May 5, 2026

@v-Kaniska244 Kaniska (v-Kaniska244) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot Why assuming ubuntu-26.04 is plucky, shouldn't it be resolute?

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Why assuming ubuntu-26.04 is plucky, shouldn't it be resolute?

You're right — Ubuntu 26.04 LTS is "Resolute Raccoon", not "Plucky" (which is 25.04). Fixed in 77dbcc3: updated codenames and test scenario to use resolute.

@v-Kaniska244 Kaniska (v-Kaniska244) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot Do a minor version bump of the feature as well

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Do a minor version bump of the feature as well

Done — bumped from 2.16.1 → 2.17.0 in 6fc10b9.

@v-Kaniska244 Kaniska (v-Kaniska244) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot Set moby: false for resolute test. As of now, moby isn't supported by ubuntu resolute.

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Set moby: false for resolute test. As of now, moby isn't supported by ubuntu resolute.

Set moby: false for the resolute test scenario in ab61fec.

@v-Kaniska244

Copy link
Copy Markdown
Contributor

Copilot Note down this exceptional behavior for ubuntu resolute in the feature documentation.

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Note down this exceptional behavior for ubuntu resolute in the feature documentation.

Added a note in src/docker-in-docker/NOTES.md documenting that Ubuntu 26.04 (Resolute) requires moby: false and automatically falls back to iptables-nft due to lack of legacy iptables kernel support. See 75d23c2.

@v-Kaniska244
Kaniska (v-Kaniska244) marked this pull request as ready for review May 5, 2026 09:43
@v-Kaniska244
Kaniska (v-Kaniska244) requested a review from a team as a code owner May 5, 2026 09:43
@v-Kaniska244
Kaniska (v-Kaniska244) merged commit 58f4a1f into main May 13, 2026
114 checks passed
@v-Kaniska244
Kaniska (v-Kaniska244) deleted the copilot/fix-docker-in-docker-ubuntu-26-04 branch May 13, 2026 09:10
@preston

Copy link
Copy Markdown

For those of us already on Ubuntu 26.04, how can we use this fix?

fork-updater Bot pushed a commit to sheeeng/microsoft-retina that referenced this pull request Nov 18, 2026
…ky installs (microsoft#2826)

# Description

The DevContainer workflow times out on every run since `ubuntu-latest`
moved to Ubuntu 26.04 on 2026-11-12.
`ghcr.io/devcontainers/features/docker-in-docker` at `2.16.1` always
selects `iptables-legacy` in the container. The Ubuntu 26.04 kernel has
no legacy iptables NAT tables, so dockerd does not start:

```
(*) Failed to start docker, retrying...
```

The `postStartCommand` then waits for `docker info` until the job
reaches its 30-minute limit. Upstream fixed this in
[devcontainers/features#1637](devcontainers/features#1637)
and moved the selection to container start in `4.0.0`.

Before that, the workflow failed often because three features download
from hosts that GitHub runners cannot reach reliably.

- **LLVM**: `ghcr.io/devcontainers-community/features/llvm` runs
`llvm.sh` from `apt.llvm.org` and adds that apt repository. The requests
to `apt.llvm.org` fail intermittently, and sometimes DNS returns only an
IPv6 address that the build container cannot reach:

  ```
[error] Distribution 'ubuntu' in version '24.04.5 LTS (Noble Numbat)' is
not supported by this script.
[error] GPG key not reachable at
https://apt.llvm.org/llvm-snapshot.gpg.key
Connecting to apt.llvm.org (apt.llvm.org)|2a04:4e42:79::561|:443...
failed: Network is unreachable.
  ```

The repository adds no packages. Its noble builds of LLVM 17
(`1:17.0.6~++…`) sort below Ubuntu's `1:17.0.6-9ubuntu1`, so apt
installs the Ubuntu packages anyway.
- **kind**: `ghcr.io/devcontainers-extra/features/kind` resolves
`latest` through the GitHub API without a token. Shared runner IPs hit
the rate limit, and `latest` can resolve to an alpha tag that has no
release:

  ```
  urllib.error.HTTPError: HTTP Error 403: rate limit exceeded

nanolayer.installers.gh_release.resolvers.asset_resolver.AssetResolver.NoReleaseError:
no release exists for repo:kubernetes-sigs/kind and tag: v0.34.0-alpha
  ```

- **Helm**: `ghcr.io/devcontainers/features/kubectl-helm-minikube`
downloads the Helm release signature from GitHub with `curl -sSL`,
without `--fail` and without a retry. When GitHub answers with an error,
`curl` saves the error body as the signature file, and `gpg --verify`
stops the build:

  ```
  Verification failed!
  gpg: no valid OpenPGP data found.
  gpg: the signature could not be verified.
  ```

The feature also installs the latest Helm release (`v4.3.2` today), not
the `v4.1.4` in `go.mod`.

The Go version check also passes when the versions differ. The Go
feature installs `1.24.11`, but `go.mod` requires `go 1.26.8`. With
`GOTOOLCHAIN=auto`, `go version` downloads and reports `go1.26.8`.

This PR:

- **Docker-in-Docker**: bumps the feature `2.16.1` → `4.1.3`. That
version selects `iptables-legacy` or `iptables-nft` at container start,
from the kernel modules of the host.
- **LLVM**: drops the feature. The `apt-deps` step installs `clang-17`
and `llvm-17` from the Ubuntu archive (the same packages as before) and
creates the `clang` and `llvm-strip` symlinks.
- **kind**: drops the feature. `sigs.k8s.io/kind` `v0.33.0` joins the
`tool` block in `go.mod`, and `go-setup` runs `go install
sigs.k8s.io/kind`. `go.mod` marks tool dependencies `// indirect`, which
Dependabot skips by default, so `dependabot.yaml` allows
`sigs.k8s.io/kind` by name. Minor and patch updates arrive with the
`k8s` group.
- **Helm**: sets the `helm` option of the feature to `none`.
`helm.sh/helm/v4/cmd/helm` joins the `tool` block in `go.mod`, and
`go-setup` installs it with kind. `helm.sh/helm/v4` is a direct
dependency, so the Helm CLI now has the version of the Helm SDK, and
Dependabot updates it already.
- **minikube**: sets the `minikube` option of the feature to `none`. The
repository uses kind, not minikube, and the feature downloads the latest
minikube release on each build. The feature still installs `kubectl`.
- **Go**: sets the Go feature to `1.26.8` and runs the version check
with `GOTOOLCHAIN=local`. Also pins `golangciLintVersion` to `2.11.4`,
the `go.mod` version that the golangci-lint workflow builds, so that the
editor lints like CI.

## Checklist

- [x] I have read the [contributing
documentation](https://retina.sh/docs/Contributing/overview).
- [x] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [x] I have correctly attributed the author(s) of the code.
- [x] I have tested the changes locally.
- [x] I have followed the project's style guidelines.
- [ ] I have updated the documentation, if necessary.
- [ ] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Built the dev container with `@devcontainers/cli` `0.90.0` (the CLI
version that `devcontainers/ci` uses) on an Ubuntu 24.04 host and ran
the workflow's `runCmd` in it. All steps pass, including the Go version
check:

```
Ubuntu clang version 17.0.6 (9ubuntu1)
Ubuntu LLVM version 17.0.6
go version go1.26.8 linux/amd64
version.BuildInfo{Version:"v4.1", GitCommit:"", GitTreeState:"", GoVersion:"go1.26.8", KubeClientVersion:"v1.36"}
kind v0.33.0 go1.26.8 linux/amd64
```

`helm` and `kind` resolve to `/go/bin`. The feature build log has no
Helm download and no minikube download, and the image has no `minikube`
binary. `go generate` rebuilds the eBPF objects, and `golangci-lint
--version` reports `2.11.4`.

Docker `29.9.3` starts in the dev container with `iptables-legacy`, the
backend that the feature selects on this host. With the alternative set
to `iptables-nft` by hand, dockerd also starts and `docker run` works.
The Ubuntu 24.04 host cannot reproduce the Ubuntu 26.04 failure, so the
DevContainer workflow run on this PR validates that path.

Signed-off-by: Quang Nguyen <[email protected]>
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.

docker-in-docker feature not working on Ubuntu 26.04

5 participants