You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-13Lines changed: 67 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Also see the [Docker Compose Buildkite Plugin](https://github.com/buildkite-plug
8
8
9
9
### `run`
10
10
11
-
The following pipeline will build a binary in the dist directory using [golang Docker image](https://hub.docker.com/_/golang/) and then uploaded as an artifact.
11
+
The following pipeline will build a binary in the dist directory using the [golang Docker image](https://hub.docker.com/_/golang/) and then uploaded as an artifact.
12
12
13
13
```yml
14
14
steps:
@@ -164,7 +164,7 @@ You can read more about runtime variable interpolation from the [docs](https://b
164
164
165
165
If the image that you want to run is not in a registry the `load` property can be used to load an image from a tar file.
166
166
167
-
This can be useful if a previous step builds an image and uploads it as an artifact. The below example shows how a artifact can be downloaded and then passed to the `load` property to load the image which can then be referred to in the `image` property to start a container and run a command as explained above.
167
+
This can be useful if a previous step builds an image and uploads it as an artifact. The below example shows how an artifact can be downloaded and then passed to the `load` property to load the image which can then be referred to in the `image` property to start a container and run a command as explained above.
168
168
169
169
```yml
170
170
steps:
@@ -177,9 +177,9 @@ steps:
177
177
image: "node:7"
178
178
```
179
179
180
-
### 🚨 Warning
180
+
### :warning: Warning
181
181
182
-
You need to be careful when/if [running the BuildKite agent itself in docker](https://buildkite.com/docs/agent/v3/docker) that, itself, runs pipelines that use this plugin. Make sure to read all the documentation on the matter, specially the caveats and warnings listed.
182
+
You need to be careful when/if [running the Buildkite agent itself in docker](https://buildkite.com/docs/agent/v3/docker) that, itself, runs pipelines that use this plugin. Make sure to read all the documentation on the matter, specially the caveats and warnings listed.
183
183
184
184
## Configuration
185
185
@@ -273,7 +273,7 @@ If you set this to `VALUE`, and `VALUE` is an environment variable containing a
273
273
274
274
When set to true, it will activate interpolation of variables in the elements of the `image` configuration variable. When turned off (the default), attempting to use variables will fail as the literal `$VARIABLE_NAME` string will be passed as the image name.
275
275
276
-
Environment variable interporation rules apply here. `$VARIABLE_NAME` is resolved at pipeline upload time, whereas `$$VARIABLE_NAME` is at run time. All things being equal, you likely want `$$VARIABLE_NAME`.
276
+
Environment variable interpolation rules apply here. `$VARIABLE_NAME` is resolved at pipeline upload time, whereas `$$VARIABLE_NAME` is at run time. All things being equal, you likely want `$$VARIABLE_NAME`.
277
277
278
278
:warning: **Important:** this is considered an unsafe option as the most compatible way to achieve this is to run the strings through `eval` which could lead to arbitrary code execution or information leaking if you don't have complete control of the pipeline
279
279
@@ -283,7 +283,7 @@ Whether or not to automatically propagate all* pipeline environment variables in
283
283
284
284
Note that only pipeline variables will automatically be propagated (what you see in the Buildkite UI). Variables set in proceeding hook scripts will not be propagated to the container.
285
285
286
-
\* Caveat: only environment variables listed in $BUILDKITE_ENV_FILE will be propagated. This does not include e.g. variables that you exported in an `environment` hook. If you wish for those to be propagated, try `env-propagation-list`.
286
+
\* Caveat: only environment variables listed in $BUILDKITE_ENV_FILE will be propagated. This does not include for example variables that you exported in an `environment` hook. If you wish for those to be propagated, try `env-propagation-list`.
@@ -345,7 +345,7 @@ Specify a file to load a docker image from. If omitted no load will be done.
345
345
346
346
Whether to automatically mount the current working directory which contains your checked out codebase. Mounts onto `/workdir`, unless `workdir` is set, in which case that will be used.
347
347
348
-
If there's a git mirror path and `mount-checkout` is enabled, the (mirror path)[https://buildkite.com/docs/pipelines/environment-variables#BUILDKITE_REPO_MIRROR] is mounted into the docker container as an added volume. Otherwise, the git mirror path will have to be explicitly added as an extra volume to mount into the container.
348
+
If there's a git mirror path and `mount-checkout` is enabled, the [mirror path](https://buildkite.com/docs/pipelines/environment-variables#BUILDKITE_REPO_MIRROR) is mounted into the docker container as an added volume. Otherwise, the git mirror path will have to be explicitly added as an extra volume to mount into the container.
Set the size of the `/dev/shm` shared memory filesystem mount inside the docker contianer. If unset, uses the default for the platform (typically `64mb`). See [docker run’s runtime constraints documentation](https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources) for information on allowed formats.
438
+
Set the size of the `/dev/shm` shared memory filesystem mount inside the docker container. If unset, uses the default for the platform (typically `64mb`). See [docker run's runtime constraints documentation](https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources) for information on allowed formats.
439
439
440
440
Example: `2gb`
441
441
@@ -475,15 +475,15 @@ Example: `mynamespace`
475
475
476
476
### `volumes` (optional, array or boolean)
477
477
478
-
Extra volume mounts to pass to the docker container, in an array. Items are specified as `SOURCE:TARGET`. Each entry corresponds to a Docker CLI `--volume` parameter. Relative local paths are converted to their full-path (e.g `./code:/app`).
478
+
Extra volume mounts to pass to the docker container, in an array. Items are specified as `SOURCE:TARGET`. Each entry corresponds to a Docker CLI `--volume` parameter. Relative local paths are converted to their full-path (for example `./code:/app`).
### `expand-volume-vars` (optional, boolean, run only, unsafe)
483
483
484
484
When set to true, it will activate interpolation of variables in the elements of the `volumes` configuration array as well as `workdir`. When turned off (the default), attempting to use variables will fail as the literal `$VARIABLE_NAME` string will be passed to the `-v` option.
485
485
486
-
Environment variable interporation rules apply here. `$VARIABLE_NAME` is resolved at pipeline upload time, whereas `$$VARIABLE_NAME` is at run time. All things being equal, you likely want `$$VARIABLE_NAME`.
486
+
Environment variable interpolation rules apply here. `$VARIABLE_NAME` is resolved at pipeline upload time, whereas `$$VARIABLE_NAME` is at run time. All things being equal, you likely want `$$VARIABLE_NAME`.
487
487
488
488
:warning: **Important:** this is considered an unsafe option as the most compatible way to achieve this is to run the strings through `eval` which could lead to arbitrary code execution or information leaking if you don't have complete control of the pipeline
489
489
@@ -493,13 +493,13 @@ Tmpfs mounts to pass to the docker container, in an array. Each entry correspond
493
493
494
494
Example: `[ "/tmp", "/root/.cache" ]`
495
495
496
-
### `workdir`(optional, string)
496
+
### `workdir`(optional, string)
497
497
498
498
The working directory to run the command in, inside the container. The default is `/workdir`. This path is also used by `mount-checkout` to determine where to mount the checkout in the container.
499
499
500
500
Example: `/app`
501
501
502
-
### `sysctls`(optional, array)
502
+
### `sysctls`(optional, array)
503
503
504
504
Set namespaced kernel parameters in the container. More information can be found in https://docs.docker.com/engine/reference/commandline/run/.
505
505
@@ -560,6 +560,60 @@ can be found in https://docs.docker.com/config/containers/resource_constraints/#
560
560
561
561
Example: `0`
562
562
563
+
## Troubleshooting
564
+
565
+
### File and Directory Permissions with Volume Mounts
566
+
567
+
When using volume mounts with Docker containers, file and directory permissions can become problematic due to user ID (UID) and group ID (GID) mismatches between the host and container environments.
568
+
569
+
#### Common Permission Issues
570
+
571
+
1. **Root-owned files**: Many Docker images run as root by default, creating files owned by root that the host user cannot modify or delete
572
+
2. **Permission denied errors**: Host files may be inaccessible inside the container if UIDs/GIDs don't match
573
+
3. **Build artifacts**: Generated files may have incorrect ownership, preventing cleanup by the Buildkite agent
574
+
575
+
#### Solutions
576
+
577
+
**Option 1: Use `propagate-uid-gid` (Recommended)**
578
+
```yml
579
+
steps:
580
+
- command: "make build"
581
+
plugins:
582
+
- docker#v5.13.0:
583
+
image: "node:18"
584
+
propagate-uid-gid: true
585
+
```
586
+
This matches the container user's UID/GID to the host user, ensuring files created in volume mounts have correct ownership.
587
+
588
+
**Option 2: Use `chown` for cleanup**
589
+
```yml
590
+
steps:
591
+
- command: "npm run build"
592
+
plugins:
593
+
- docker#v5.13.0:
594
+
image: "node:18"
595
+
chown: true
596
+
```
597
+
This changes ownership of the checkout directory back to the agent user after the container exits.
598
+
599
+
**Option 3: Specify explicit user**
600
+
```yml
601
+
steps:
602
+
- command: "python setup.py build"
603
+
plugins:
604
+
- docker#v5.13.0:
605
+
image: "python:3.9"
606
+
user: "1000:1000" # Match your host user's UID:GID
607
+
```
608
+
609
+
#### Troubleshooting Permission Issues
610
+
611
+
If you encounter permission errors:
612
+
1. Check file ownership with `ls -la` on both host and container
613
+
2. Verify UID/GID matching between host user and container user
614
+
3. Consider using `propagate-uid-gid: true` to automatically handle ID mapping
615
+
4. For persistent issues, use `chown: true` as a fallback solution
616
+
563
617
## Container Labels
564
618
565
619
When running a command, the plugin will automatically add the following Docker labels to the container:
@@ -582,7 +636,7 @@ This behaviour can be disabled with the `run-labels: false` option.
582
636
583
637
## Developing
584
638
585
-
To run testing, shellchecks and plugin linting use use `bk run` with the [Buildkite CLI](https://github.com/buildkite/cli).
639
+
To run testing, shellchecks and plugin linting use `bk run` with the [Buildkite CLI](https://github.com/buildkite/cli).
0 commit comments