Skip to content

Commit 8c25821

Browse files
committed
feat(docker): add option for explicit GID for Docker socket
- Introduces `GITHUB_RUNNER_DOCKER_SOCK_GID` to allow users to specify a custom GID for the Docker socket group. - Enhances the existing Docker socket handling logic to use the specified GID if provided, otherwise defaults to auto-detection. - Improves flexibility for configuring runner permissions in varied environments.
1 parent db769ed commit 8c25821

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ In ephemeral mode, the runner will:
9797
- `GITHUB_RUNNER_WORKDIR` (optional): Working directory for jobs
9898
- `GITHUB_RUNNER_GID` (optional): Custom GID to create github-actions-runner group
9999
- `GITHUB_RUNNER_DOCKER_SOCK` (optional): Set to "true" to auto-configure Docker socket access
100+
- `GITHUB_RUNNER_DOCKER_SOCK_GID` (optional): Explicit GID for Docker socket group (overrides auto-detection when socket exists)
100101
- `GITHUB_RUNNER_EPHEMERAL` (optional): Set to "true" to configure runner in ephemeral mode (single job only)
101102

102103
##### Pre-configured Environment Variables

src/entrypoint.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,19 @@ setup_groups() {
136136
# Handle Docker socket access if requested
137137
if [ "${GITHUB_RUNNER_DOCKER_SOCK}" = "true" ]; then
138138
if [ -S /var/run/docker.sock ]; then
139-
DOCKER_GID=$(stat -c '%g' /var/run/docker.sock)
140-
echo "Docker socket detected with GID ${DOCKER_GID}"
141-
echo "Creating github-actions-runner-dockersock group..."
139+
# Socket exists, determine the GID to use
140+
if [ -n "${GITHUB_RUNNER_DOCKER_SOCK_GID}" ]; then
141+
# Use explicitly configured GID
142+
DOCKER_GID="${GITHUB_RUNNER_DOCKER_SOCK_GID}"
143+
echo "Using configured Docker socket GID ${DOCKER_GID}"
144+
else
145+
# Auto-detect GID from socket
146+
DOCKER_GID=$(stat -c '%g' /var/run/docker.sock)
147+
echo "Docker socket detected with GID ${DOCKER_GID}"
148+
fi
149+
150+
# Create group with the determined GID
151+
echo "Creating github-actions-runner-dockersock group with GID ${DOCKER_GID}..."
142152
sudo groupadd -f -g ${DOCKER_GID} github-actions-runner-dockersock || true
143153
sudo usermod -aG github-actions-runner-dockersock runner
144154
echo "Added runner user to github-actions-runner-dockersock group"

0 commit comments

Comments
 (0)