Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Docker permissions #114

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
- ${REPO_CURATED}:${REPO_CURATED}:ro
- ${REPO_CONFIG}:${REPO_CONFIG}:ro
# docker plugin requires a shared workspace
# docker-in-docker can't share an internal workspace so we need
# an external volume
- ./docker-workspace:/home/omero/workspace
environment:
- SLAVE_NAME=docker
- SLAVE_PARAMS=-labels docker -disableClientsUniqueId -executors ${DOCKER_EXECUTORS}
Expand Down
1 change: 1 addition & 0 deletions docker-workspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ RUN yum -y install docker-ce

# Change user id to fix permissions issues
ARG USER_ID=1000
RUN usermod -u $USER_ID omero
RUN usermod -u $USER_ID -aG docker omero

COPY run.sh /tmp/run.sh
RUN chmod a+x /tmp/run.sh
USER omero
# Start as root so docker permissions can be fixed
# Drop to omero in startup script
CMD ["/tmp/run.sh"]
13 changes: 12 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#!/bin/bash

/tmp/jenkins-slave.sh
set -eu
set -x

# Adjust docker permissions
# https://github.com/jenkinsci/docker/issues/263#issuecomment-217955379
sudo groupmod -g $(stat -c %g /var/run/docker.sock) docker
sudo usermod -aG docker omero
# This is mounted from outside, so you may need to fix permissions
# https://support.cloudbees.com/hc/en-us/articles/360000304932-Pipeline-jobs-fail-to-run-in-a-Docker-in-Docker-step
#sudo chown omero /home/omero/workspace

exec sudo -iu omero env SLAVE_PARAMS="$SLAVE_PARAMS" SLAVE_EXECUTORS="$SLAVE_EXECUTORS" SLAVE_NAME="$SLAVE_NAME" JENKINS_MASTER="$JENKINS_MASTER" /tmp/jenkins-slave.sh