Skip to content

Instantly share code, notes, and snippets.

@AjeetK
Created November 11, 2017 17:05
Show Gist options
  • Save AjeetK/dff33e592e9e44497cc040920dd862b5 to your computer and use it in GitHub Desktop.
Save AjeetK/dff33e592e9e44497cc040920dd862b5 to your computer and use it in GitHub Desktop.
Adding jenkins User To Docker Group
DOCKER_SOCKET=/var/run/docker.sock
DOCKER_GROUP=docker
JENKINS_USER=jenkins

if [ -S ${DOCKER_SOCKET} ]; then
DOCKER_GID=$(stat -c '%g' ${DOCKER_SOCKET})
sudo groupadd -for -g ${DOCKER_GID} ${DOCKER_GROUP}
sudo usermod -aG ${DOCKER_GROUP} ${JENKINS_USER}
fi

# Restart Jenkins service
sudo service jenkins restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment