Share workspace path between runner and dind for job bind mounts
This commit is contained in:
1 parent
239a3b2057
commit
e769c3df3a
3 files changed
+56
-1
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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
|
||||
+5
-1
@@ -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
|
||||
Reference in new issue
Block a user