PROBLEM
After GitLab changed its pricing, I migrated our organization's repositories to GitHub. One of the bigger issues in that migration was setting up self-hosted runners.
GitLab's runner is a single binary with a simple TOML config and just works. GitHub's self-hosted runner is a lot more involved — bash scripts, hundreds of .NET Core DLLs, and a more complicated setup overall. GitLab's runner also has a concurrent parameter to run multiple jobs in parallel; GitHub's doesn't have an equivalent, so running several jobs at once means running several runner instances.
Here's how I set that up.
SUMMARY
myoung34/docker-github-actions-runner handles this well — self-spawning, self-hosted GitHub Actions runners in Docker, with Docker-in-Docker support.
Usage docs: docker-github-actions-runner usage
SETUP
I avoided using a personal access token (PAT) tied to a person's account for organization-wide runners, and used a GitHub App instead. You'll need the Owner role on the GitHub organization to set one up.
1. Create the app under your organization
Create it at the organization level (not your personal account) so ownership stays tied to the org, not to you.
- Go to
https://github.com/organizations/<your-org>/settings/apps - Click New GitHub App
- Fill in an app name (e.g.
org-runner-manager) and homepage URL - Under Webhook, uncheck Active unless you actually want event-driven runners
2. Configure permissions
Repository permissions:
- Administration: Read & write (needed for runner registration at repo scope)
- Actions: Read-only
- Metadata: Read-only (default)
Organization permissions (required for org-wide runners):
- Self-hosted runners: Read & write
- Organization administration: Read-only (or Read & write to manage runner groups)
- Organization custom repository roles: Read-only (optional, enterprise only)
Under "Where can this GitHub App be installed?", choose Only on this account, then click Create GitHub App.
3. Get the App ID and generate a private key
- On the app's General settings page, note the numeric App ID
- Scroll to Private keys, click Generate a private key
- GitHub downloads a
.pemfile — keep it secure
4. Install the app on the organization
- In the sidebar, click Install App
- Install it on your organization
- Choose repository access — all repos, or only selected ones
- Verify at
https://github.com/organizations/<your-org>/settings/installations
5. Run the runner container
The image handles JWT creation, token exchange, and registration automatically from the App credentials:
export APP_PRIVATE_KEY_CONTENTS="$(cat /path/to/org-runner-manager.*.private-key.pem)"
docker run -d --restart always --name github-runner-org \
-e RUNNER_SCOPE="org" \
-e ORG_NAME="your-organization" \
-e APP_ID="1313114" \
-e APP_PRIVATE_KEY="${APP_PRIVATE_KEY_CONTENTS}" \
-e APP_LOGIN="your-organization" \
-e RUNNER_NAME="org-runner-01" \
-e LABELS="self-hosted,linux,docker" \
-e UNSET_CONFIG_VARS="true" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/runner-work:/tmp/runner-work \
myoung34/github-runner:latest
-
APP_LOGINis the org slug or user login the App is installed under -
UNSET_CONFIG_VARS="true"removes the private key and generated tokens from the runner's environment after it boots
Security note (added 4 December 2026, after a reader comment): this does not protect the key from jobs in the setup above. With the Docker socket mounted, any job controls the host's Docker daemon, and docker inspect shows the variables the container was started with. The compose version below does not share the socket, but privileged: true is still close to root on the host. It does not hide the key either: jobs run as root by default in this image, and a root job can read the container's original environment, private key included, from /proc/1/environ. Give the App as few permissions as you can, and use either only for private repos where you trust everyone who can edit a workflow.
Running several replicas
For running multiple runner instances on one machine, a compose file with replicas is simpler than managing individual docker run commands. Rough shape (trim the org-specific bits — CA cert, Gradle/Java tuning — to whatever applies to you):
services:
runner:
image: myoung34/github-runner:latest
privileged: true
restart: always
stop_grace_period: 2m
volumes:
- /var/lib/docker
ulimits:
nofile:
soft: 524288
hard: 524288
environment:
EPHEMERAL: "1"
START_DOCKER_SERVICE: "true" # run a dockerd inside each runner
DISABLE_AUTO_UPDATE: "true"
RUNNER_SCOPE: org
ORG_NAME: your-organization
APP_ID: ${APP_ID}
APP_PRIVATE_KEY: ${APP_PRIVATE_KEY}
RUNNER_NAME_PREFIX: linux-runner
RANDOM_RUNNER_SUFFIX: "true" # so replicas don't collide on name
LABELS: self-hosted,Linux
logging:
driver: json-file
options: { max-size: "50m", max-file: "3" }
deploy:
replicas: 6
mem_limit: 16g
cpus: 4
replicas: 6 with RANDOM_RUNNER_SUFFIX gives six independent runners registered under distinct names, all pulling jobs from the same org queue.
THINGS THAT BITE LATER
Added 4 December 2026, from reader comments.
-
Updates: the example sets
DISABLE_AUTO_UPDATEbecause it is based on my setup, where I manage updates myself. If you copy it, you take on that job too: GitHub stops assigning jobs to a runner that is not updated within 63 days of a new release. Update the image on a schedule, for example weekly withdocker compose pull && docker compose up -d. - Public repos: by default only private repositories can use a runner group. Keep it that way, because a pull request from a fork can run any code on your runner.
-
Disk:
restart: alwaysbrings back the same container and volume, so images and build cache pile up. Prune each replica periodically, for example from cron in the compose folder:docker compose ps -q runner | xargs -I{} docker exec {} docker system prune -af --filter until=72h. It leaves volumes alone and goes by creation date, not last use, so run it when the runners are idle. -
Restarts: recreating containers can kill a running job, and
stop_grace_period: 2mis shorter than many jobs. Update when the queue is empty.
Originally posted on htsh.pl/blog/multiple-github-runners
Top comments (6)
Nice writeup, and the GitHub App instead of a PAT plus
UNSET_CONFIG_VARSare the two things most guides skip. Three things that bite this exact setup a few weeks in:DISABLE_AUTO_UPDATE: "true"has a deadline. GitHub stops assigning jobs to a self-hosted runner whose version is more than 30 days behind a new release. With auto-update off, all six replicas go idle at once one day, with jobs just queued and no error on the runner side. Either pin the image tag and bump it on a schedule (a weeklydocker compose pull && docker compose up -dis enough), or let it auto-update, which withEPHEMERALonly happens between jobs anyway.Org runners and public repos. The org's Default runner group doesn't serve public repositories unless "Allow public repositories" is ticked. That's the right default, because a fork PR can run arbitrary code. If you do enable it,
privileged: trueplus Docker-in-Docker means that code is root inside a container with its own dockerd, so keep those runners in a separate group restricted to the private repos.EPHEMERALcleans the runner, not/var/lib/docker. Each replica's anonymous volume keeps every image and build cache its jobs pulled, and withrestart: alwaysthe same container (and volume) comes back after each job. Six of them on one disk fill up quietly. A periodicdocker exec <replica> docker system prune -af --filter until=72hor a size check in the job's pre-step keeps that in check.One small one:
stop_grace_period: 2mis shorter than most real jobs. On acompose upthat recreates the containers, a job running at the time gets killed mid-step, so do restarts when the queue is empty or raise the grace period.Thanks
updates are disabled in the example because it comes from my own setup, where I manage them myself on maintenance schedule. I've added a note to the post for anyone copying it. One correction: GitHub's docs currently give 63 days before jobs stop being assigned, not 30: docs.github.com/en/actions/referen...
agreed, keeping public repos off these runners is the right call. I'd go a bit further on privileged: true: I wouldn't treat the container as a boundary at all, since root inside it can generally get to the host.
I had this issue. My fix is in the compose command: wipe /var/lib/docker and /_work on every start, then start dockerd. With EPHEMERAL the container restarts after each job, so every job starts clean, at the price of no cache between jobs. I've added it to the post.
You're right, 63 days. I had an old number in my head, thanks for correcting it.
Wiping
/var/lib/dockeron every start is the honest fix. If the lost cache starts to hurt, you can get most of it back without sharing state between jobs. Run one pull-through registry mirror (registry:2withREGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io) as its own container on the host, and point each runner's dockerd at it with--registry-mirror. Base image pulls then come from local disk, and a job can only read from that cache, not write into the next job's daemon. For build layers,docker buildx build --cache-from/--cache-to type=registry,ref=<mirror-or-ghcr>/cache:<branch>does the same thing per branch.Thank you, that's a really cool idea, and it might work better in some cases than the Nexus I use for dependencies and the registry within individual steps.
One thing worth knowing about the single docker run example: with /var/run/docker.sock mounted, any job on that runner can talk to the host's Docker daemon, and
docker inspect github-runner-orgshows the container env exactly as it was passed with -e, private key included. UNSET_CONFIG_VARS clears it inside the runner, not in the container config the daemon keeps. The compose version with its own /var/lib/docker avoids the shared socket, though privileged: true is still close to root on the host. Either way it fits private repos best, which is also what GitHub's docs recommend for self-hosted runners.You're right, and my wording on
UNSET_CONFIG_VARSwas too strong. It cleans the environment inside the runner, but with the host socket mounted a job can still ask the daemon with docker inspect and get the App private key back. I'll update the post.Agreed on the rest too: the compose variant drops the shared socket, but privileged: true is still close to root on the host, so neither is a real isolation boundary. I'd only run this for private repos where you trust everyone who can change a workflow. For anything beyond that, a throwaway VM per job is the safer setup.