jenkinsci / jenkinsci/docker-plugin
RFE: Specify user to run a container (as docker run --user name:group)
- Dominant language
- Java
- Stars
- 498
- Forks
- 324
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 2
Description
We use Docker slaves, and inside the image we create a user `jenkins`:
```
RUN useradd jenkins -m -d /build
```
We also use a volume for cached dependencies downloaded by Groovy Grapes. Without this volume, each new Docker slave would download all dependencies, making the build much slower.
This leads to a problem: all downloaded and cached dependencies belong to some irrelevant user, that by chance has the same uid as the user `jenkins` in the container:
```
drwxrwxr-x. 3 itinvent itinvent 4096 Apr 11 15:26 aopalliance
drwxrwxr-x. 3 itinvent itinvent 4096 Apr 11 15:27 com.clearspring.analytics
...
```
With console docker client, we could fix this problem by running the container as user `jenkins`:
```
docker run --user jenkins my_image
```
However, there is no such option in the Docker Plugin configuration.
A workaround is to create user `jenkins` on the host machine running Docker containers with the same uid and gid as within the container. With many images and many host machines, this workaround seems poor.
Jenkins 2.164.2
Docker Plugin 1.1.6
Docker Commons Plugin 1.14
Contributor guide
Assessment
This issue has not been assessed yet.