Skip to content

Commit 81cecbb

Browse files
committed
Also mount /var/lib/containerd on a volume for DinD buildkit
Buildkit (embedded in dockerd) uses containerd's overlayfs snapshotter for cache mounts. Its layer dirs live under /var/lib/containerd. If that path sits on the workspace's overlay writable layer, the kernel refuses the nested overlay mount (redirect_dir=off, EINVAL). Add a second per-workspace docker volume (containerd_data) mounted at /var/lib/containerd so the snapshotter has a non-overlay backing, same fix pattern as /var/lib/docker.
1 parent 45677ae commit 81cecbb

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,29 @@ resource "docker_volume" "docker_data" {
463463
}
464464
}
465465

466+
# /var/lib/containerd needs its own non-overlay backing for the same reason
467+
# as /var/lib/docker: buildkit (embedded in dockerd) uses containerd's
468+
# overlayfs snapshotter for cache mounts, and the kernel refuses nested
469+
# overlay with redirect_dir=off when the underlying dirs sit on an overlay.
470+
resource "docker_volume" "containerd_data" {
471+
name = "coder-${data.coder_workspace.me.id}-containerd-data"
472+
lifecycle {
473+
ignore_changes = all
474+
}
475+
labels {
476+
label = "coder.owner"
477+
value = data.coder_workspace_owner.me.name
478+
}
479+
labels {
480+
label = "coder.owner_id"
481+
value = data.coder_workspace_owner.me.id
482+
}
483+
labels {
484+
label = "coder.workspace_id"
485+
value = data.coder_workspace.me.id
486+
}
487+
}
488+
466489
# Per-workspace projects volume. Cloned repos + work-in-progress live here
467490
# so they survive workspace restarts. $HOME itself is image-owned and resets
468491
# each start; per-owner state that must persist outside projects goes through
@@ -567,6 +590,12 @@ resource "docker_container" "workspace" {
567590
read_only = false
568591
}
569592

593+
volumes {
594+
container_path = "/var/lib/containerd"
595+
volume_name = docker_volume.containerd_data.name
596+
read_only = false
597+
}
598+
570599
# home_persist and shared are NOT terraform-managed — they're owned outside
571600
# this workspace's lifecycle (per-owner and deployment-wide respectively).
572601
# Referencing them by name means workspace destroy won't try to remove them

0 commit comments

Comments
 (0)