Skip to content

Commit 6a28f2d

Browse files
authored
[docker-in-docker] - Fixing issue with containerd (#1653)
* [docker-in-docker] - Fixing issue with containerd * Change the base image used for stress test as its not compatible with ubuntu resolute * Change test base image
1 parent a646de4 commit 6a28f2d

8 files changed

Lines changed: 78 additions & 7 deletions

File tree

.github/workflows/docker-in-docker-stress-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run: npm install -g @devcontainers/cli
2020

2121
- name: "Generating tests for 'docker-in-docker' which validates if docker daemon is running"
22-
run: devcontainer features test --skip-scenarios -f docker-in-docker -i mcr.microsoft.com/devcontainers/base:ubuntu .
22+
run: devcontainer features test --skip-scenarios -f docker-in-docker -i mcr.microsoft.com/devcontainers/base:noble .
2323

2424
test-onCreate:
2525
strategy:
@@ -34,4 +34,4 @@ jobs:
3434
run: npm install -g @devcontainers/cli
3535

3636
- name: "Generating tests for 'docker-in-docker' which validates if docker daemon is available within 'onCreateCommand'"
37-
run: devcontainer features test -f docker-in-docker --skip-autogenerated --filter "docker_with_on_create_command"
37+
run: devcontainer features test -f docker-in-docker --skip-autogenerated --filter "docker_with_on_create_command" -i mcr.microsoft.com/devcontainers/base:noble

.github/workflows/test-pr-arm64.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ jobs:
4747
]
4848
exclude:
4949
- features: docker-in-docker
50-
baseImage: mcr.microsoft.com/devcontainers/base:debian
50+
baseImage: mcr.microsoft.com/devcontainers/base:debian
51+
- features: docker-in-docker
52+
baseImage: mcr.microsoft.com/devcontainers/base:ubuntu
5153
steps:
5254
- uses: actions/checkout@v6
5355

.github/workflows/test-pr.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ jobs:
6565
- features: docker-in-docker
6666
baseImage: mcr.microsoft.com/devcontainers/base:debian
6767
- features: docker-outside-of-docker
68-
baseImage: mcr.microsoft.com/devcontainers/base:debian
68+
baseImage: mcr.microsoft.com/devcontainers/base:debian
69+
- features: docker-in-docker
70+
baseImage: mcr.microsoft.com/devcontainers/base:ubuntu
6971
steps:
7072
- uses: actions/checkout@v6
7173

src/docker-in-docker/NOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,14 @@ Debian Trixie (13) does not include moby-cli and related system packages, so the
1818
Ubuntu 26.04 (Resolute) does not currently have moby packages available, so the feature cannot install with "moby": "true". To use this feature on Resolute, please set "moby": "false". Additionally, the kernel on Ubuntu 26.04 no longer supports legacy iptables NAT tables, so the feature automatically falls back to `iptables-nft` when `iptables-legacy` is not functional.
1919

2020
`bash` is required to execute the `install.sh` script.
21+
22+
## Persisted state
23+
24+
This Feature mounts two named Docker volumes into the dev container so that the daemons have writable, non-overlay storage for their state:
25+
26+
* `dind-var-lib-docker-${devcontainerId}``/var/lib/docker`
27+
* `dind-var-lib-containerd-${devcontainerId}``/var/lib/containerd`
28+
29+
The `/var/lib/containerd` mount is required when the dev container's root filesystem is itself an overlayfs mount (the default in Kubernetes / containerd-backed hosts, GitHub Codespaces, and Docker with the containerd image store enabled). Without it, the standalone `containerd` started by this Feature would place its overlayfs snapshotter data on an overlay rootfs, causing overlay-on-overlay mounts to fail with `invalid argument`. See [issue #1639](https://github.com/devcontainers/features/issues/1639) for background.
30+
31+
Because both volumes are scoped to `${devcontainerId}`, each dev container gets its own state and rebuilds preserve images and snapshots. Removing the dev container does not automatically remove these volumes; clean them up with `docker volume rm` if you want to reclaim space.

src/docker-in-docker/devcontainer-feature.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "docker-in-docker",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"name": "Docker (Docker-in-Docker)",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-in-docker",
66
"description": "Create child containers *inside* a container, independent from the host's docker instance. Installs Docker extension in the container along with needed CLIs.",
@@ -86,6 +86,11 @@
8686
"source": "dind-var-lib-docker-${devcontainerId}",
8787
"target": "/var/lib/docker",
8888
"type": "volume"
89+
},
90+
{
91+
"source": "dind-var-lib-containerd-${devcontainerId}",
92+
"target": "/var/lib/containerd",
93+
"type": "volume"
8994
}
9095
],
9196
"installsAfter": [

test/docker-in-docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ubuntu:focal
1+
FROM ubuntu:noble
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# Regression test for devcontainers/features#1639 / PR #1645 follow-up:
4+
# verifies that when the dev container's root filesystem is overlayfs
5+
# (the default under Docker / containerd-backed hosts), the standalone
6+
# containerd started by the docker-in-docker Feature does NOT place its
7+
# overlayfs snapshotter data on an overlay rootfs (which would fail with
8+
# `invalid argument` when pulling images).
9+
#
10+
set -e
11+
12+
source dev-container-features-test-lib
13+
14+
# 1. Confirm we're really reproducing the affected condition:
15+
# the dev container's / must be overlay.
16+
check "rootfs is overlay (precondition)" \
17+
bash -c '[ "$(findmnt -no FSTYPE /)" = "overlay" ]'
18+
19+
# 2. The Feature's volume mount must shadow /var/lib/containerd with a
20+
# non-overlay filesystem. Without the mount, containerd's overlayfs
21+
# snapshotter would be writing onto the overlay rootfs and fail at
22+
# pull time.
23+
check "/var/lib/containerd is not overlay" \
24+
bash -c '[ "$(findmnt -no FSTYPE /var/lib/containerd)" != "overlay" ]'
25+
26+
check "/var/lib/docker is not overlay" \
27+
bash -c '[ "$(findmnt -no FSTYPE /var/lib/docker)" != "overlay" ]'
28+
29+
# 3. The actual symptom: pulling and running an image must succeed.
30+
# Pre-PR-#1645 this fails with:
31+
# failed to mount /tmp/containerd-mountXXXXX ... err: invalid argument
32+
check "docker run hello-world" \
33+
docker run --rm hello-world
34+
35+
# 4. Belt-and-braces: confirm dockerd is actually using the
36+
# containerd-snapshotter path so we know this test exercises the
37+
# affected code path, not the legacy overlay2 driver.
38+
check "containerd-snapshotter active" \
39+
bash -c "docker info 2>/dev/null | grep -qiE 'driver-type: io.containerd.snapshotter.v1|Storage Driver: overlayfs'"
40+
41+
reportResults
42+

test/docker-in-docker/scenarios.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2+
"overlayfs_containerd_root": {
3+
"image": "mcr.microsoft.com/devcontainers/base:noble",
4+
"features": {
5+
"docker-in-docker": {
6+
"version": "latest",
7+
"moby": true
8+
}
9+
}
10+
},
211
"docker_build_fallback_compose": {
312
"image": "ubuntu:noble",
413
"features": {
@@ -108,7 +117,7 @@
108117
}
109118
},
110119
"docker_python_bookworm": {
111-
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
120+
"image": "mcr.microsoft.com/devcontainers/base:2.1.8-bookworm",
112121
"features": {
113122
"docker-in-docker": {
114123
"moby": true,

0 commit comments

Comments
 (0)