A minimal Ubuntu 22.04 Docker image for GitHub Actions self-hosted runners, optimized for use with GitHub Runner Controller in Kubernetes.
- Base: Official GitHub Actions Runner image (Ubuntu 22.04 LTS)
- GitHub Actions Runner: Latest version (v2.330.0)
- Pre-installed Tools:
- Git, curl, jq, rsync, openssh-client
- Essential utilities (zip, unzip, sudo)
- Automatic Registration: Automatically registers with GitHub on startup
- Ephemeral Mode: Runs as ephemeral runner (removes itself after job completion)
- Graceful Shutdown: Properly deregisters from GitHub on container stop
- Minimal Footprint: Optimized for Kubernetes deployments
- Automated Builds: Docker image automatically built and published to GitHub Container Registry
The image is automatically built and published to GitHub Container Registry on every push to main branch and on tagged releases.
docker pull ghcr.io/pashkadez/selfhosted_runner_docker_image:latestlatest- Latest build from main branchv*- Semantic versioned releases (e.g.,v1.0.0,1.0,1)main- Latest from main branch<runner-version>- Pinned to the GitHub Actions runner version baked into the image (e.g.,2.330.0)runner-<runner-version>- Explicit runner-version tag for clarity (e.g.,runner-2.330.0)<commit-sha>- Specific commit (full 40-character SHA)
- Docker installed (for local testing)
- GitHub Personal Access Token (PAT) with appropriate permissions:
- For repository runners:
reposcope - For organization runners:
admin:orgscope
- For repository runners:
docker run -d \
--name github-runner \
-e GH_TOKEN=your_token \
-e GH_OWNER=your_owner \
-e GH_REPOSITORY=your_repo \
ghcr.io/pashkadez/selfhosted_runner_docker_image:latest-
Clone this repository:
git clone https://github.com/pashkadez/selfhosted_runner_docker_image.git cd selfhosted_runner_docker_image -
Copy the example environment file and configure it:
cp .env.example .env
-
Edit
.envwith your settings:GH_TOKEN=your_github_personal_access_token GH_OWNER=your_github_username_or_org GH_REPOSITORY=your_repository_name # Optional: omit for org-level runner RUNNER_NAME=my-runner RUNNER_LABELS=self-hosted,Linux,x64 -
Start the runner:
docker-compose up -d
-
Check the logs:
docker-compose logs -f
-
Build the image:
docker build -t github-actions-runner:latest . -
Run the container:
docker run -d \ --name github-runner \ -e GH_TOKEN=your_token \ -e GH_OWNER=your_owner \ -e GH_REPOSITORY=your_repo \ github-actions-runner:latest
| Variable | Required | Description |
|---|---|---|
GH_TOKEN |
Yes | GitHub Personal Access Token |
GH_OWNER |
Yes | GitHub username or organization name |
GH_REPOSITORY |
No | Repository name (omit for org-level runner) |
RUNNER_NAME |
No | Custom runner name (defaults to hostname) |
RUNNER_LABELS |
No | Comma-separated labels (default: self-hosted,Linux,x64) |
RUNNER_WORKDIR |
No | Work directory (default: _work) |
RUNNER_GROUP |
No | Runner group for org runners (default: Default) |
| Software | Version |
|---|---|
| Ubuntu | 22.04 LTS |
| GitHub Actions Runner | 2.330.0 |
| Git | Latest |
| curl | Latest |
| jq | Latest |
| rsync | Latest |
| openssh-client | Latest |
This image is optimized for use with the GitHub Actions Runner Controller in Kubernetes environments.
Extend the Dockerfile to add more tools as needed for your workflows:
FROM ghcr.io/pashkadez/selfhosted_runner_docker_image:latest
USER root
RUN apt-get update && apt-get install -y your-package
USER runnerUpdate the RUNNER_VERSION build argument:
docker build --build-arg RUNNER_VERSION=2.330.0 -t github-actions-runner:latest .This repository uses GitHub Actions to automatically build and publish the Docker image:
- On push to main: Builds and publishes with
latestand commit SHA tags - On tag push (v)*: Publishes with semantic version tags
- On pull request: Builds only (no push) for validation
- Check the container logs:
docker-compose logs github-runner - Verify your PAT has the correct scopes
- Ensure GH_OWNER and GH_REPOSITORY are correct
If you see permission errors, ensure:
- The runner user has appropriate permissions
- Volume mounts have correct ownership
This project is open source and available under the MIT License.