Skip to content
🧮 Is Lifetime with ZapX Pass worth it? Work it out for your own servers in 30 seconds. Open the Lifetime calculator →

Set Up GitHub Runner on a Linux Server – GitHub Actions on Your Own Server

Set up a self-hosted GitHub Actions runner on a Linux server as a One-Click App or with Docker Compose, including tokens, labels, and security tips.

2 December 202614 min read4 Views0 helpful

Introduction

A GitHub Actions runner is the program that runs your GitHub workflow jobs: checking out code, building, testing, creating Docker images, or deploying to a server. Normally, these jobs run on GitHub's servers. With a self-hosted runner, they run on your own VPS. The runner has no web interface of its own. It signs in to GitHub, waits there for jobs, and appears under Runners in your repository or organization settings.

The One-Click App installs the myoung34/github-runner Docker image. In this guide, we'll show you two ways to set it up: the easy way as a One-Click App and the manual installation with Docker Compose. Both methods require an access token from GitHub that the runner uses to register itself. Then you'll send your first workflow to the runner and learn what to keep in mind for security.

When a dedicated GitHub runner on a VPS makes sense

GitHub-hosted runners are sufficient for many projects. A dedicated runner on a VPS is worthwhile if:

  • You don't have enough Actions minutes. Jobs on self-hosted runners don't count against your GitHub account's Actions minutes quota.
  • Your builds benefit from a cache. The runner retains dependencies, Docker layers, and working files between jobs. This often makes repeated builds significantly faster.
  • The job needs access to your server. A deployment job can start containers directly on the VPS or access services that are only available internally, without you having to open a port to the outside.
  • You need specific tools and versions. On your runner, you decide which software is installed and how much CPU and RAM a build gets.

A dedicated runner is less suitable for public repositories. Anyone can submit code through a pull request, and your runner will then run it on your server. A Linux VPS is also not the right place for jobs that need macOS, Windows, or a graphics card.

Repository runner or organization runner?

You can register a runner for a single repository or for an entire organization. You set this during installation with RUNNER_SCOPE:

Repository runnerOrganization runner
RUNNER_SCOPErepo (default)org
Required valueREPO_URL, e.g. https://github.com/YOUR-NAME/YOUR-REPOORG_NAME, e.g. your-organization
Available toThis repository onlyAll organization repositories that you enable in GitHub
Token permission (fine-grained token)Repository permission Administration: Read and writeOrganization permission Self-hosted runners: Read and write
Token permission (classic token)repoadmin:org
Suitable forYour own projects, one team, one repositoryMultiple repositories with a shared build environment

We recommend starting with a repository runner. It's quick to set up, and the token only needs access to a single repository. A personal account without an organization can only use repository runners.

The easy way: GitHub runner as a One-Click App

The quickest way to set up your own runner is through your VPS's One-Click Apps. Enter your repository address and a token; the container takes care of the rest when it starts.

Requirements

  • A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set up One-Click Apps for instructions.
  • A GitHub repository where you have admin permissions, or an organization where you're an owner. Use a private repository; see “Security: private repositories only.”
  • The runner itself needs 256 MB of RAM, but plan for at least 2 GB of RAM and 20 GB of storage for actual builds. The image alone takes up just under 4 GB when extracted, in addition to caches and Docker images from your builds.

Create a token in GitHub

The runner registers itself with GitHub every time it starts. To do this, it needs a personal access token. The runner uses this token to get the actual registration token from GitHub, which is valid for only one hour. We recommend a fine-grained token that can access just one repository:

  1. Sign in to GitHub and open your profile picture in the top right > Settings > Developer settings > Personal access tokens > Fine-grained tokens.
  2. Click Generate new token, enter a name such as runner-vps, and choose an Expiration date.
  3. Under Resource owner, select your account or the organization that owns the repository.
  4. Set Repository access to Only select repositories and choose the repository for the runner.
  5. Under Permissions, set Administration to Read and write. The runner doesn't need any other permissions.
  6. Click Generate token and copy the token immediately. GitHub only displays it once.

For an organization runner, select the organization under Resource owner, then set Self-hosted runners to Read and write under Organization permissions. A classic token (Tokens (classic)) also works. It needs the repo or admin:org scope, but applies to all repositories your account can access.

Warning: The token is powerful

The Administration permission allows the token to change repository settings. Therefore, give it access to only that one repository, set an expiration date, and don't share it with anyone. If it expires, the runner won't be able to register after its next restart.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search for Github Runner in the app catalog and click Install app.
  3. Under App name, enter a name that will help you recognize the runner. This app doesn't have a domain because the runner has no web interface and doesn't open a port.
  4. Expand App configuration and enter the values from the table below. ACCESS_TOKEN and REPO_URL are required (or ORG_NAME for an organization runner). The runner won't start without them, even if the form marks all fields as optional.
  5. Click Queue installation.
FieldDescriptionExample
REPO_URLFull repository address; required when RUNNER_SCOPE = repohttps://github.com/YOUR-NAME/YOUR-REPO
ACCESS_TOKENYour GitHub token; requiredgithub_pat_...
RUNNER_SCOPErepo for a repository, org for an organizationrepo
ORG_NAMEOrganization name; only for RUNNER_SCOPE = orgyour-organization
LABELSCustom runner labels, separated by commasvps,docker
RUNNER_NAME_PREFIXPrefix for the runner name in GitHubcoolify-runner
RUNNER_NAME_SUFFIXHas no effect with the image being used; leave the default valuefalse

The first image download takes a few minutes and is around 1.7 GB. The container then starts and registers with GitHub. Since the runner has no web interface, the app card won't show an Access link.

Check whether the runner is connected

You can see whether everything worked in GitHub, not in the panel:

  1. Open your repository on GitHub and click Settings > Actions > Runners. For an organization, find the list in the organization's settings under Actions > Runners.
  2. A runner named coolify-runner- followed by a random suffix will appear there. The Idle status means the runner is connected and waiting for jobs.
  3. Click the runner to see its labels: self-hosted, Linux, X64, and your custom labels from LABELS.

In the panel, open the runner's output using the Logs icon on the app card. After successful registration, the last line should say Listening for Jobs. If the runner doesn't appear in GitHub, see “If the runner won't start.”

Info: A new name after every restart

When stopped, the runner signs out of GitHub. The next time it starts, it signs in again with a new random name. This is normal. If the container is stopped abruptly, for example because the VPS crashes, the old entry remains as Offline. You can remove it in GitHub under Runners by opening the runner's menu and selecting Remove.

Run your first workflow on the runner

A workflow uses your runner when runs-on includes the self-hosted label. Create the file .github/workflows/runner-test.yml in your repository:

Code
name: Runner-Test

on:
  workflow_dispatch:

jobs:
  test:
    runs-on: [self-hosted, default]
    steps:
      - uses: actions/checkout@v5
      - run: uname -a
      - run: docker version

On GitHub, start the workflow from the Actions tab by clicking Run workflow. The job will now run on your VPS, and its status in the Runners list will briefly change to Active. The default label comes from the default value of LABELS. If you set custom labels there, use those instead.

Security: private repositories only

A runner executes any code a workflow sends it. This leads to two rules:

  • Only use the runner for private repositories you trust. In a public repository, anyone can open a pull request with a modified workflow, and your runner will execute that code on your server. GitHub itself advises against using self-hosted runners for public repositories.
  • A job has full control over your VPS. The One-Click App passes the server's Docker socket (/var/run/docker.sock) to the runner so your workflows can build Docker images and start containers. Anyone who can control Docker on the server can also read, stop, or delete all other containers and effectively has root privileges. Your token is also accessible to a job.
Warning: Don't run untrusted pull requests on your runner

For repositories that other people contribute to, go to Settings > Actions > General in GitHub and require approval for workflows from forks. It's best to run the runner on a VPS that doesn't host any other important services.

Updates and backup

The runner program keeps itself up to date. When a new version is released, the runner downloads it and restarts. GitHub requires this: runners that are more than 63 days behind the current version no longer receive jobs. To apply new templates from the app catalog, open the app settings (gear icon), go to App update, and click Check for updates and Apply update. If it says the app is up to date, there is no newer template.

There isn't much to back up. The runner renews its registration itself every time it starts. The app's data volume only contains working files and caches from your jobs. The important things are to keep your workflows in the repository and your token in your password manager.

If your token expires or you want to replace it, create a new one in GitHub, open the App environment tab using the gear icon on the app card, enter it under App configuration in ACCESS_TOKEN, and click Save. The panel only shows the token in masked form there. The app then restarts and registers with the new token. You can change REPO_URL, LABELS, or the other values the same way later.

If the runner won't start

If a value is missing or the token is invalid, the runner exits on startup and the container automatically restarts shortly afterward. The app card then shows Failed or Degraded, along with a note to check the logs and settings. The cause is shown in the app card's Logs. Over SSH, you can view the same output with these two commands:

Code
docker ps -a --format '{{.Names}}' | grep '^runner-'
docker logs --tail 50 runner-ID

Replace runner-ID with the name from the first line. These are the most common messages and what they mean:

Message in the logsCauseSolution
REPO_URL required for repo runners, followed by Invalid configuration provided for urlREPO_URL is emptyEnter the full repository address
ORG_NAME required for org runnersRUNNER_SCOPE is set to org, but ORG_NAME is missingEnter the organization name
Invalid configuration provided for token, preceded by curl: (22) The requested URL returned error: 401 for an invalid tokenACCESS_TOKEN is empty, was copied incorrectly, or has expiredCreate and enter a new token
curl: (22) The requested URL returned error: 403 or 404The token doesn't have admin permissions for this repository, or REPO_URL is misspelledCheck the token permissions and the address spelling

Correct the value under App environment and click Save. The app restarts with the new values. Your token won't appear in these messages.

Manual installation

The rest of this guide describes the manual installation of the runner with Docker Compose on your VPS, for example if you don't use One-Click Apps on the server or need settings that aren't available in the form. We'll use the same image as the One-Click App, but at a fixed version.

Requirements

  • A Linux VPS running Debian or Ubuntu, with SSH access; see First SSH connection.
  • Docker and Docker Compose (Compose v2); see Install Docker. Check the installation with docker --version and docker compose version.
  • A GitHub token as described above under “Create a token in GitHub.”

The values below are for a runner handling typical builds. The image alone takes up just under 4 GB when extracted. Large projects, concurrent containers, or extensive Docker images need more.

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM256 MB2 GB
Storage8 GB20 GB

Prepare the firewall

The runner establishes its own connection to GitHub over outbound HTTPS (port 443). It doesn't need an open port. With ufw, you only need to allow SSH:

Code
ufw allow OpenSSH
ufw enable

If other services are running on the VPS, allow their ports as well. For more information about the firewall, see Firewall management on Linux.

Install with Docker Compose

Create a directory for the runner:

Code
mkdir -p /opt/github-runner
cd /opt/github-runner

Create the .env file for your token (nano .env) and protect it so only root can read it:

Code
ACCESS_TOKEN=YOUR_TOKEN
Code
chmod 600 .env

Then create the docker-compose.yml file (nano docker-compose.yml) and add this content:

Code
services:
  runner:
    image: myoung34/github-runner:2.338.2-ubuntu-noble
    container_name: github-runner
    restart: unless-stopped
    environment:
      RUNNER_SCOPE: repo
      REPO_URL: https://github.com/YOUR-NAME/YOUR-REPO
      ACCESS_TOKEN: ${ACCESS_TOKEN}
      RUNNER_NAME: vserver-runner
      LABELS: vserver,docker
      RUNNER_WORKDIR: /tmp/github-runner/work
      UNSET_CONFIG_VARS: "true"
    security_opt:
      - label:disable
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /tmp/github-runner:/tmp/github-runner

Here's what the important lines mean:

  • image: The runner image at a fixed version. Available versions are listed on Docker Hub. The runner program inside still updates itself if GitHub requires a new version.
  • RUNNER_SCOPE and REPO_URL: Where the runner registers. For an organization, set RUNNER_SCOPE: org and ORG_NAME: your-organization, and omit REPO_URL.
  • ACCESS_TOKEN: Your token from the .env file. The runner exchanges it for a registration token every time it starts.
  • RUNNER_NAME: A fixed name. Without it, the image generates a random name every time it starts.
  • LABELS: Custom labels used to target the runner in runs-on.
  • RUNNER_WORKDIR and /tmp/github-runner: The jobs' working directory. It is on the host at the same path as in the container. This is necessary because containers started by your jobs run directly on the host and expect the checked-out files to be at the same path.
  • UNSET_CONFIG_VARS: Removes the token and settings from the environment before jobs run.
  • /var/run/docker.sock: Gives jobs access to the server's Docker, as described in the warning under “Security: private repositories only.” If your workflows don't need Docker, omit this line.

Download the image and start the runner:

Code
docker compose pull
docker compose up -d

Register and check the runner

Registration happens automatically when the runner starts. Follow the container output:

Code
docker compose logs -f

Startup is successful when Listening for Jobs appears at the end. Stop viewing the output with Ctrl + C. The runner should now appear in GitHub under Settings > Actions > Runners with the Idle status. Start your first workflow as described above under “Run your first workflow on the runner.”

For more tips on securing your server, see Linux security tips.

Back up data

The runner doesn't store any data you can't recover. Back up the docker-compose.yml and .env files from /opt/github-runner; that's all you need to rebuild it. The /tmp/github-runner directory only contains job working files and can be empty.

Update the runner

Change the image version in docker-compose.yml and restart:

Code
cd /opt/github-runner
docker compose pull
docker compose up -d
docker image prune

When stopped, the runner signs out of GitHub. When started, it registers again. docker image prune then removes the old image.

Workflows on your own runner

Once setup is complete, you can target jobs to your runner and build with Docker.

Target jobs with labels

GitHub selects the runner using the labels in runs-on. Every self-hosted runner automatically has self-hosted, Linux, and X64, as well as your custom labels. A job with runs-on: [self-hosted, vserver] will only run on runners that have both labels. If runs-on is still set to ubuntu-latest, the job will continue to use GitHub's servers as before. This lets you move individual jobs to your runner while leaving the rest on GitHub.

A runner only runs one job at a time. Other jobs wait until it's available. If you need more concurrency, install a second runner with the same labels.

Docker in workflows

Since the server's Docker socket is passed through, docker build, docker run, and docker compose work directly in your jobs. Images built by a job are stored on the VPS itself. This speeds up subsequent builds but uses storage, so clean up occasionally with docker image prune.

With the One-Click App, the jobs' working directory is in a Docker volume. If you start a container yourself in a job and mount files from the working directory, for example with docker run -v $PWD:/app, that container won't see the files. The same applies to jobs that use container: and to actions that run as Docker containers. In this case, build images with docker build and copy the files in with COPY, or use the manual installation, where the working directory is on the host at the same path.

Remove the runner

If you uninstall the One-Click App or stop the container with docker compose down, the runner signs out of GitHub. If an Offline entry still remains in GitHub, remove it under Runners by opening the runner's menu and selecting Remove. If you no longer need the token, also delete it from Fine-grained tokens in GitHub.

Limitations

  • Linux jobs only: The runner runs in a Linux container. Workflows for Windows or macOS need a runner on those systems.
  • No preinstalled software like GitHub's: GitHub's runners come with many languages and tools preinstalled. On your runner, install them with actions such as actions/setup-node or actions/setup-python.
  • One job at a time: Each runner processes jobs one after another. You need multiple runners to run jobs in parallel.
  • Not a substitute for a clean environment: Files and images remain between jobs. This speeds up builds but can affect results. Clean up in your workflows if a job needs a fresh environment.

Conclusion

With your own GitHub runner, your workflows now run on your server, with their own cache and without using up Actions minutes. To go with it, the guide Set Up Docker Registry on a Linux Server shows you how to store the images built in your workflows in a private registry.

If you have any other questions or need help, our support team is available every day! 🙂

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the fastest option: enter the repository URL and token, and the panel takes care of the rest. The Runner program also keeps itself up to date. Manual installation with Docker Compose is a good choice if you need a fixed Runner name, a specific image version, or Docker container actions that can access the checked-out files. Both options use the same image.
A personal access token (PAT), which the Runner uses to fetch a registration token each time it starts. For the best security, use a fine-grained token that can access only one repository and has the Administration permission set to Read and write. For an organization Runner, the token needs the Self-hosted runners organization permission set to Read and write. Don't enter the short-lived registration token from the Runner page on GitHub.
We don't recommend it, and neither does GitHub. Anyone can open a pull request to a public repository with a modified workflow, and your Runner will then run that code on your VPS. Since the Runner has access to the server's Docker, third-party code would effectively gain full control of the server. Use the Runner only for private repositories you trust.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.