Share workspace path between runner and dind for job bind mounts

This commit is contained in:
agentbox committed 2026-11-05 16:34:21 +00:00
1 parent 239a3b2057
commit e769c3df3a
3 files changed
+56 -1

No files matched your search

+44
View File
@@ -251,6 +251,50 @@ Storage Driver: overlayfs
Cached images and builds in the old dind store are discarded by this reset. 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 ## Networking details
- `dind` has no published Docker API port. - `dind` has no published Docker API port.
+7
View File
@@ -6,6 +6,9 @@ networks:
ci: ci:
driver: bridge driver: bridge
volumes:
ci-workspace:
services: services:
gitea: gitea:
image: docker.gitea.com/gitea image: docker.gitea.com/gitea
@@ -35,6 +38,7 @@ services:
- ALL - ALL
volumes: volumes:
- ./dind-data:/var/lib/docker - ./dind-data:/var/lib/docker
- ci-workspace:/workspace
- ./dind-runsc/resolv.conf:/etc/resolv.conf:ro - ./dind-runsc/resolv.conf:/etc/resolv.conf:ro
# Use the disk-backed dind-data volume with Docker 29's containerd # Use the disk-backed dind-data volume with Docker 29's containerd
# snapshotter, which supports file-capability xattrs. # snapshotter, which supports file-capability xattrs.
@@ -56,3 +60,6 @@ services:
GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-} GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-}
volumes: volumes:
- ./runner:/data - ./runner:/data
# Same path as dind so workflow bind mounts like -v "$repo_dir:/app"
# resolve on the dind daemon too.
- ci-workspace:/workspace
+5 -1
View File
@@ -23,7 +23,11 @@ container:
# Jobs share dind's sandbox network namespace. # Jobs share dind's sandbox network namespace.
network: host network: host
privileged: false 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 force_pull: false
host: host:
workdir_parent: # Must be the same path mounted into dind as /workspace.
workdir_parent: /workspace