gh-self-hosted-runner
Lightweight image for self-hosted GitHub runner. Supports repo- and org-level, auto token refresh
1.1K
Lightweight, self-hosted GitHub Actions runner in Docker â works for both repositories and organizations, with automatic token refresh, Docker-in-Docker, and easy
.envsetup.
Ideal for scalable CI/CD setups or on-premise runner environments.
.env filesgh) pre-installed for advanced GitHub operationsWICHTIG: Self-hosted Runner mit Docker-Socket-Zugriff sollten NUR fĂźr private, vertrauenswĂźrdige Repositories verwendet werden!
repo and workflow scopes (see instructions belowâ )All configuration is done via environment variables, which can be set in .env files, via docker-compose, or directly with docker run.
| Variable | Type | Required | Default | Description |
|---|---|---|---|---|
RUNNER_SCOPE | String | No | repos | Runner scope: repos or orgs |
REPO_URL | String | Yes | - | GitHub repository or organization URL |
ACCESS_TOKEN | String | Yes | - | GitHub PAT with repo and workflow scopes (see belowâ ) |
RUNNER_NAME | String | No | Container hostname | Custom runner name |
LABELS | String | No | self-hosted,linux,x64,docker | Comma-separated labels for workflow targeting |
DOCKER_GID | Integer | No | 999 | Host Docker group ID (see belowâ ) |
RUNNER_ARCH | String | No | x64 | Runner architecture (x64 or arm64) |
ENABLE_DIND | Boolean | No | false | Enable Docker-in-Docker mode |
.env files (Recommended)RUNNER_SCOPE=repos # or "orgs" for organization-level
REPO_URL=https://github.com/ORGANIZATION/REPO
ACCESS_TOKEN=ghp_your_token_here
RUNNER_NAME=my-runner
LABELS=docker,linux
DOCKER_GID=999
RUNNER_ARCH=x64 # Optional: auto-detected, specify for arm64
ENABLE_DIND=false # Set to true for Docker-in-Docker mode
docker-compose --env-file .env-repo up -d
ENABLE_DIND=true docker-compose --env-file .env-repo up -d
docker run -d -e RUNNER_SCOPE=repos -e REPO_URL=https://github.com/owner/repo \
-e ACCESS_TOKEN=ghp_xxx -e RUNNER_NAME=my-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/shopping2go/gh-self-hosted-runner-docker:latest
Create a Personal Access Tokenâ with repo and workflow scopes. See: GitHub documentationâ
getent group docker | cut -d: -f3 # Output: 999
Set ENABLE_DIND=true to run a separate Docker daemon inside the container. Default is false (uses host Docker socket).
â ď¸ Important: Privileged Mode Required
Docker-in-Docker requires privileged mode to function properly. The container needs elevated privileges to:
How to enable privileged mode:
Using docker run:
docker run --privileged -e ENABLE_DIND=true ...
Using docker-compose.yml (already configured):
services:
github-runner:
privileged: ${ENABLE_DIND:-false} # Automatically enabled when ENABLE_DIND=true
The included docker-compose.yml is pre-configured to enable privileged mode when ENABLE_DIND=true is set in your environment.
Security Warning: Privileged mode gives the container full access to the host system. Only use Docker-in-Docker with trusted workloads in isolated environments.
Storage Driver: The daemon will attempt to use the overlay2 storage driver for optimal performance. If overlay2 is not supported (e.g., due to kernel restrictions), it will automatically fall back to the vfs driver, which is slower but more compatible.
Alternative: Host Docker Socket
If you don't need a full Docker daemon inside the container, you can mount the host's Docker socket instead:
docker run -v /var/run/docker.sock:/var/run/docker.sock:rw ...
This is the default behavior when ENABLE_DIND=false.
Choose and configure one of the methods described in the Environment Variablesâ section above.
# For repository runner
docker-compose --env-file .env-repo up -d
# For organization runner
docker-compose --env-file .env-org up -d
After startup, the runner should be visible in GitHub:
Settings â Actions â RunnersSettings â Actions â RunnersThe runner should be displayed as "Idle" or "Active".
config.shThe Docker image comes with several essential tools pre-installed:
GitHub CLI (gh) - Direct GitHub API interaction and automation
- name: Create GitHub Issue
run: |
gh issue create --title "Build Failed" --body "Details here"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Docker CLI - Docker-in-Docker support for containerized builds
Git - Version control operations
jq - JSON processing for API responses
Maven - Java build automation
Python 3 - Python runtime and pip package manager
.
âââ .github/
â âââ workflows/
â âââ docker-ghcr.yml # CI/CD workflow for building and pushing Docker images
âââ Dockerfile # Image definition
âââ docker-compose.yml # Container setup
âââ start.sh # Runner bootstrap & token refresh logic
âââ .env-org # Environment file for organization runner
âââ .env-repo # Environment file for repository runner
âââ LICENSE
Licensed under the MIT License â see LICENSEâ for details.
Die Nutzung dieses Projekts erfolgt vollständig auf eigene Gefahr. Die Maintainer ßbernehmen keine Gewähr fßr die Funktionsfähigkeit, Sicherheit oder Eignung des Codes fßr einen bestimmten Zweck. Insbesondere wird keine Haftung ßbernommen fßr direkte oder indirekte Schäden, Datenverlust, entgangene Gewinne oder sonstige Folgeschäden, die aus der Nutzung oder UnmÜglichkeit der Nutzung dieses Projekts entstehen.
Der Nutzer ist allein verantwortlich fĂźr die Implementierung zusätzlicher SicherheitsmaĂnahmen, Backups und PrĂźfprozesse vor dem produktiven Einsatz. Es obliegt dem Anwender, dieses Projekt in einer geeigneten, abgesicherten Umgebung zu betreiben (z.,B. isolierte Netzwerke, eingeschränkte Zugriffsrechte, least-privilege PATs).
Der Nutzer stellt die Maintainer von allen Ansprßchen Dritter frei, die aus der Nutzung dieses Projekts resultieren, soweit gesetzlich zulässig.
Hinweis: Dies stellt keine Rechtsberatung dar. FĂźr eine rechtsverbindliche Haftungsbegrenzung oder rechtliche Absicherung sollte ein qualifizierter Rechtsbeistand konsultiert werden.
GitHub Actions, self-hosted runner, Docker, CI/CD, automation, repository runner, organization runner, token refresh, workflow runner, Docker-in-Docker, DevOps
Content type
Image
Digest
sha256:ef7adebbbâŚ
Size
670.3 MB
Last updated
3 months ago
docker pull shopping2go/gh-self-hosted-runner:2026-04-22