From 6f19f8652287f5d2b3d33997645e77f482f61900 Mon Sep 17 00:00:00 2001 From: agentbox Date: Thu, 5 Nov 2026 14:59:00 +0000 Subject: [PATCH] Use disk-backed containerd snapshotter in dind --- .gitignore | 1 - README.md | 87 +++++---------------- docker-compose.yml | 8 +- gvisor/images/basic/docker/start-dockerd.sh | 19 ++++- host/daemon.json.example | 47 ----------- 5 files changed, 39 insertions(+), 123 deletions(-) delete mode 100644 host/daemon.json.example diff --git a/.gitignore b/.gitignore index fc89a21..403a07a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .env gitea/ dind-data/ -dind-overlay/ runner/.runner runner/.cache/ *.log diff --git a/README.md b/README.md index 606a9b0..620d2d5 100644 --- a/README.md +++ b/README.md @@ -182,16 +182,24 @@ The dind image comes from the gVisor Docker-in-gVisor example under The default Compose configuration starts dind with: ```yaml -command: --no-overlay +command: --disk-store ``` 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 -tmpfs size. The startup script also disables Docker 29's containerd snapshotter -for this mode. +`./dind-data` volume. It keeps Docker 29's containerd snapshotter enabled, which +supports image layers containing `security.capability` xattrs. -If you prefer a bounded RAM-backed store, remove `command: --no-overlay` and set -`DOCKER_TMPFS_SIZE` explicitly: +The dind image is built from `gvisor/images/basic/docker`. Its startup script +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 environment: @@ -207,66 +215,14 @@ failed to register layer: lsetxattr /usr/bin/ping: xattr "security.capability": operation not supported ``` -This is not a registry or authentication problem. gVisor's host-backed -filesystem path cannot set the `security.capability` xattr on files such as -`/usr/bin/ping`, which many Ubuntu runner images contain. +This happens when dind uses `--no-overlay` (Docker 29 classic overlay2/vfs) +on a host-backed volume. gVisor's host-backed filesystem path cannot set the +`security.capability` xattr in that mode. -The disk-backed dind setup needs an overlay filestore to support those xattrs. -A host daemon configuration example with the required runtime change is included -at: - -```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. +Use `--disk-store` instead. It keeps the containerd snapshotter enabled and the +disk-backed volume, and image pulls with file capabilities work. The old +`--no-overlay` mode is retained only for compatibility and is not recommended +for runner images containing files such as `/usr/bin/ping`. ## Networking details @@ -302,6 +258,5 @@ runner/config.yaml gvisor/images/basic/docker/Dockerfile gvisor/images/basic/docker/start-dockerd.sh dind-runsc/resolv.conf -host/daemon.json.example scripts/workflow-*.yml ``` diff --git a/docker-compose.yml b/docker-compose.yml index 2a808dc..2b4b3e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,12 +35,10 @@ services: - ALL volumes: - ./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 - # Use the disk-backed dind-data volume instead of a RAM-backed tmpfs. - command: --no-overlay + # Use the disk-backed dind-data volume with Docker 29's containerd + # snapshotter, which supports file-capability xattrs. + command: --disk-store # No published TCP Docker API port. networks: - ci diff --git a/gvisor/images/basic/docker/start-dockerd.sh b/gvisor/images/basic/docker/start-dockerd.sh index 9390067..041960e 100755 --- a/gvisor/images/basic/docker/start-dockerd.sh +++ b/gvisor/images/basic/docker/start-dockerd.sh @@ -16,11 +16,22 @@ set -xe -o pipefail -USE_OVERLAY_DRIVER=true +USE_TMPFS=true +DISABLE_CONTAINERD_SNAPSHOTTER=false while [[ $# -gt 0 ]]; do case $1 in --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 ;; *) @@ -32,7 +43,7 @@ done # 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 # 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") if [[ "${current_fs}" != "tmpfs" ]]; then 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 # 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 [[ "${USE_OVERLAY_DRIVER}" != "true" ]]; then + if [[ "${DISABLE_CONTAINERD_SNAPSHOTTER}" == "true" ]]; then EXTRA_DOCKERD_FLAGS+=(--feature containerd-snapshotter=false) fi fi diff --git a/host/daemon.json.example b/host/daemon.json.example deleted file mode 100644 index 80f60ef..0000000 --- a/host/daemon.json.example +++ /dev/null @@ -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" - ] - } - } -}