Last active
September 11, 2017 18:37
-
-
Save batandwa/b88997390f34dc533d48f6d966ddd6af to your computer and use it in GitHub Desktop.
Docker and GoSu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Explained at https://stackoverflow.com/questions/36781372/docker-using-gosu-vs-user#37931896 | |
set -x | |
# get gid of docker socket file | |
SOCK_DOCKER_GID=`ls -ng /var/run/docker.sock | cut -f3 -d' '` | |
# get group of docker inside container | |
CUR_DOCKER_GID=`getent group docker | cut -f3 -d: || true` | |
# if they don't match, adjust | |
if [ ! -z "$SOCK_DOCKER_GID" -a "$SOCK_DOCKER_GID" != "$CUR_DOCKER_GID" ]; then | |
groupmod -g ${SOCK_DOCKER_GID} docker | |
fi | |
if ! groups jenkins | grep -q docker; then | |
usermod -aG docker jenkins | |
fi | |
# drop access to jenkins user and run jenkins entrypoint | |
exec gosu jenkins /bin/tini -- /usr/local/bin/jenkins.sh "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment