修复容器内的 jenkins 用户无法加入 docker 用户组的问题。 (#2)

This commit is contained in:
2023-03-28 00:46:48 +08:00
committed by GitHub
parent 2f5c99e4b7
commit bd0799561f
2 changed files with 30 additions and 3 deletions

26
start-agent.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
if [ $(id -u) != "0" ]; then
echo "This script must be run as root"
exit 1
fi
if [ -z "$GID" ]; then
echo "GID is not set"
exit 1
fi
if [ -z "$UID" ]; then
echo "UID is not set"
exit 1
fi
if ! grep -q docker /etc/group; then
groupadd -g $GID docker && usermod -aG docker jenkins
echo "Added docker group"
fi
if [ $(id -u jenkins) -ne $UID ]; then
usermod -u $UID jenkins
echo "Changed jenkins UID"
fi
echo "Starting agent..."
runuser -u jenkins -m -g docker -- /bin/bash /usr/local/bin/jenkins-agent $@