From e769c3df3a90cde59ed486290f940c4b19701eff Mon Sep 17 00:00:00 2001 From: agentbox Date: Thu, 5 Nov 2026 16:34:21 +0000 Subject: [PATCH] Share workspace path between runner and dind for job bind mounts --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 7 +++++++ runner/config.yaml | 6 +++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0291f04..9bbabd5 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,50 @@ Storage Driver: overlayfs Cached images and builds in the old dind store are discarded by this reset. +## Workspace bind mounts inside jobs + +A workflow step such as: + +```bash +docker run -v "$repo_dir:/app" ... +``` + +fails if `$repo_dir` only exists in the job container. The Docker daemon doing the +bind mount is dind, and it resolves the source path in **its own** filesystem. + +The deployment prevents this by sharing a workspace volume at the same path in +both containers: + +```yaml +volumes: + ci-workspace: + +services: + dind: + volumes: + - ci-workspace:/workspace + + runner: + volumes: + - ci-workspace:/workspace +``` + +Runner config: + +```yaml +container: + bind_workdir: true + +host: + workdir_parent: /workspace +``` + +With this, the job workspace is under `/workspace/...` on the runner, the same +path is visible to dind, and dind can bind that path into nested containers. + +Without this shared path, use Docker named volumes or avoid bind mounts that +refer to job-only paths. + ## Networking details - `dind` has no published Docker API port. diff --git a/docker-compose.yml b/docker-compose.yml index 2b4b3e2..fa77800 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,9 @@ networks: ci: driver: bridge +volumes: + ci-workspace: + services: gitea: image: docker.gitea.com/gitea @@ -35,6 +38,7 @@ services: - ALL volumes: - ./dind-data:/var/lib/docker + - ci-workspace:/workspace - ./dind-runsc/resolv.conf:/etc/resolv.conf:ro # Use the disk-backed dind-data volume with Docker 29's containerd # snapshotter, which supports file-capability xattrs. @@ -56,3 +60,6 @@ services: GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-} volumes: - ./runner:/data + # Same path as dind so workflow bind mounts like -v "$repo_dir:/app" + # resolve on the dind daemon too. + - ci-workspace:/workspace diff --git a/runner/config.yaml b/runner/config.yaml index 4e03c58..b1293f6 100644 --- a/runner/config.yaml +++ b/runner/config.yaml @@ -23,7 +23,11 @@ container: # Jobs share dind's sandbox network namespace. network: host privileged: false + # Use a host path for the workspace instead of an anonymous Docker volume, + # so Docker bind mounts from inside the job also resolve in dind. + bind_workdir: true force_pull: false host: - workdir_parent: + # Must be the same path mounted into dind as /workspace. + workdir_parent: /workspace