Use disk-backed containerd snapshotter in dind

This commit is contained in:
agentbox committed 2026-11-05 14:59:00 +00:00
1 parent 4b55d6e402
commit 6f19f86522
5 files changed
+39 -123

No files matched your search

-1
View File
@@ -1,7 +1,6 @@
.env .env
gitea/ gitea/
dind-data/ dind-data/
dind-overlay/
runner/.runner runner/.runner
runner/.cache/ runner/.cache/
*.log *.log
+21 -66
View File
@@ -182,16 +182,24 @@ The dind image comes from the gVisor Docker-in-gVisor example under
The default Compose configuration starts dind with: The default Compose configuration starts dind with:
```yaml ```yaml
command: --no-overlay command: --disk-store
``` ```
This skips the RAM-backed tmpfs at `/var/lib/docker` and uses the disk-backed This skips the RAM-backed tmpfs at `/var/lib/docker` and uses the disk-backed
`./dind-data` volume instead, so image/build storage is not capped at a fixed `./dind-data` volume. It keeps Docker 29's containerd snapshotter enabled, which
tmpfs size. The startup script also disables Docker 29's containerd snapshotter supports image layers containing `security.capability` xattrs.
for this mode.
If you prefer a bounded RAM-backed store, remove `command: --no-overlay` and set The dind image is built from `gvisor/images/basic/docker`. Its startup script
`DOCKER_TMPFS_SIZE` explicitly: supports three modes:
```text
(no flag) RAM-backed tmpfs at /var/lib/docker
--disk-store disk-backed volume, containerd snapshotter enabled
--no-overlay disk-backed volume, containerd snapshotter disabled
```
If you prefer a bounded RAM-backed store, remove `command: --disk-store` and
set `DOCKER_TMPFS_SIZE` explicitly:
```yaml ```yaml
environment: environment:
@@ -207,66 +215,14 @@ failed to register layer: lsetxattr /usr/bin/ping:
xattr "security.capability": operation not supported xattr "security.capability": operation not supported
``` ```
This is not a registry or authentication problem. gVisor's host-backed This happens when dind uses `--no-overlay` (Docker 29 classic overlay2/vfs)
filesystem path cannot set the `security.capability` xattr on files such as on a host-backed volume. gVisor's host-backed filesystem path cannot set the
`/usr/bin/ping`, which many Ubuntu runner images contain. `security.capability` xattr in that mode.
The disk-backed dind setup needs an overlay filestore to support those xattrs. Use `--disk-store` instead. It keeps the containerd snapshotter enabled and the
A host daemon configuration example with the required runtime change is included disk-backed volume, and image pulls with file capabilities work. The old
at: `--no-overlay` mode is retained only for compatibility and is not recommended
for runner images containing files such as `/usr/bin/ping`.
```text
host/daemon.json.example
```
The relevant entry is:
```json
"runsc-docker": {
"path": "/usr/bin/runsc",
"runtimeArgs": [
"--net-raw",
"--allow-packet-socket-write",
"--overlay2=all:dir=/var/lib/gvisor-overlay"
]
}
```
Merge that runtime entry into the host's `/etc/docker/daemon.json`, then restart
the Docker daemon.
The Compose file mounts:
```text
./dind-overlay -> /var/lib/gvisor-overlay
```
With that runtime argument, Docker inside the sandbox may report the `vfs`
storage driver rather than overlay2, but image pulls with file capabilities work
and storage remains disk-backed.
Without this host runtime change, the working alternative is the RAM-backed
tmpfs mode above. The error is a gVisor filesystem/xattr limitation, not a
runner-image label or Compose volume problem.
## Performance (local test)
Short microbenchmarks with the disk-backed dind setup (`--no-overlay`, Docker
29.9.3, overlay2). The gVisor column used the same gVisor runtime flags as
`runsc-docker`; the host used for testing only exposes an inner gVisor runtime,
so this is an approximation of the target host.
| Workload | dind under runc | dind under gVisor |
| --- | ---: | ---: |
| 2 GiB write | 2.7 GB/s | 2.4 GB/s |
| 2 GiB read | 18.2 GB/s | 13.6 GB/s |
| 2 GiB memory touch | 1.51 s | 1.94 s |
| BusyBox awk 10M loop | 5.22 s | 5.23 s |
Storage was the full disk-backed volume, not a 5 GiB tmpfs. Nested image builds
and outbound networking worked in both runs.
These are short microbenchmarks; benchmark actual CI images for planning.
## Networking details ## Networking details
@@ -302,6 +258,5 @@ runner/config.yaml
gvisor/images/basic/docker/Dockerfile gvisor/images/basic/docker/Dockerfile
gvisor/images/basic/docker/start-dockerd.sh gvisor/images/basic/docker/start-dockerd.sh
dind-runsc/resolv.conf dind-runsc/resolv.conf
host/daemon.json.example
scripts/workflow-*.yml scripts/workflow-*.yml
``` ```
+3 -5
View File
@@ -35,12 +35,10 @@ services:
- ALL - ALL
volumes: volumes:
- ./dind-data:/var/lib/docker - ./dind-data:/var/lib/docker
# Used by runsc --overlay2=all:dir=... to support file-capability xattrs
# on host-backed image layers. See README.
- ./dind-overlay:/var/lib/gvisor-overlay
- ./dind-runsc/resolv.conf:/etc/resolv.conf:ro - ./dind-runsc/resolv.conf:/etc/resolv.conf:ro
# Use the disk-backed dind-data volume instead of a RAM-backed tmpfs. # Use the disk-backed dind-data volume with Docker 29's containerd
command: --no-overlay # snapshotter, which supports file-capability xattrs.
command: --disk-store
# No published TCP Docker API port. # No published TCP Docker API port.
networks: networks:
- ci - ci
+15 -4
View File
@@ -16,11 +16,22 @@
set -xe -o pipefail set -xe -o pipefail
USE_OVERLAY_DRIVER=true USE_TMPFS=true
DISABLE_CONTAINERD_SNAPSHOTTER=false
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--no-overlay) --no-overlay)
USE_OVERLAY_DRIVER=false # Legacy gVisor behavior: skip tmpfs and disable the containerd
# snapshotter. This can fail on images with security.capability xattrs.
USE_TMPFS=false
DISABLE_CONTAINERD_SNAPSHOTTER=true
shift
;;
--disk-store)
# Use the disk-backed /var/lib/docker volume but keep Docker 29's
# containerd snapshotter. This supports file-capability xattrs.
USE_TMPFS=false
DISABLE_CONTAINERD_SNAPSHOTTER=false
shift shift
;; ;;
*) *)
@@ -32,7 +43,7 @@ done
# When dockerd uses the overlay storage driver, it will try to mount an overlay # When dockerd uses the overlay storage driver, it will try to mount an overlay
# filesystem under /var/lib/docker. gVisor only supports tmpfs as an upper # filesystem under /var/lib/docker. gVisor only supports tmpfs as an upper
# layer, so we mount a tmpfs if it isn't already present. # layer, so we mount a tmpfs if it isn't already present.
if [[ "${USE_OVERLAY_DRIVER}" == "true" ]]; then if [[ "${USE_TMPFS}" == "true" ]]; then
current_fs=$(stat -f -c %T /var/lib/docker 2>/dev/null || echo "none") current_fs=$(stat -f -c %T /var/lib/docker 2>/dev/null || echo "none")
if [[ "${current_fs}" != "tmpfs" ]]; then if [[ "${current_fs}" != "tmpfs" ]]; then
mkdir -p /var/lib/docker mkdir -p /var/lib/docker
@@ -47,7 +58,7 @@ docker_version=$(dockerd --version)
# Docker 29+ does not automatically fall back to the vfs driver when it cannot # Docker 29+ does not automatically fall back to the vfs driver when it cannot
# mount an overlayfs, so we explicitly disable it when --no-overlay is passed. # mount an overlayfs, so we explicitly disable it when --no-overlay is passed.
if [[ ${docker_version} =~ version\ ([0-9]+) ]] && [[ ${BASH_REMATCH[1]} -ge 29 ]]; then if [[ ${docker_version} =~ version\ ([0-9]+) ]] && [[ ${BASH_REMATCH[1]} -ge 29 ]]; then
if [[ "${USE_OVERLAY_DRIVER}" != "true" ]]; then if [[ "${DISABLE_CONTAINERD_SNAPSHOTTER}" == "true" ]]; then
EXTRA_DOCKERD_FLAGS+=(--feature containerd-snapshotter=false) EXTRA_DOCKERD_FLAGS+=(--feature containerd-snapshotter=false)
fi fi
fi fi
-47
View File
@@ -1,47 +0,0 @@
{
"default-runtime": "runsc",
"experimental": true,
"fixed-cidr-v6": "fd00:dead:beef:c0::/80",
"ip6tables": true,
"ipv6": true,
"runtimes": {
"runsc": {
"path": "/usr/bin/runsc"
},
"runsc-docker": {
"path": "/usr/bin/runsc",
"runtimeArgs": [
"--net-raw",
"--allow-packet-socket-write",
"--overlay2=all:dir=/var/lib/gvisor-overlay"
]
},
"runsc-host": {
"path": "/usr/bin/runsc",
"runtimeArgs": [
"--network=host"
]
},
"runsc-host-docker": {
"path": "/usr/bin/runsc",
"runtimeArgs": [
"--net-raw",
"--allow-packet-socket-write",
"--network=host"
]
},
"runsc-host-socket": {
"path": "/usr/bin/runsc",
"runtimeArgs": [
"--host-uds=all",
"--network=host"
]
},
"runsc-socket": {
"path": "/usr/bin/runsc",
"runtimeArgs": [
"--host-uds=all"
]
}
}
}