---
title: Self-hosted runners in a sandbox
description: Run the official GitHub Actions runner as a service in a sandbox that stays awake, with pols runner add, ls and rm.
---

Instead of a [fresh sandbox per job](/docs/runners/quickstart/), you can keep one sandbox as a persistent self-hosted runner for a repository or a GitHub organization. `pols runner` sets it up from the CLI: it runs the official [actions/runner](https://github.com/actions/runner) in the sandbox as a systemd service.

```sh
pols runner add --repo acme/web                      # a small sandbox, runner-acme-web
pols runner add --org acme --size large --name acme-big
pols runner ls
pols runner rm runner-acme-web                       # deregister; the sandbox may sleep
pols runner rm runner-acme-web --delete-sandbox
```

Use it when you need what the per-job runners do not give: a runner for a personal account's or a public repository, state that stays between jobs, or labels of your own.

## Adding a runner

`pols runner add --repo OWNER/REPO` (or `--org ORG` for all of an organization's repositories):

1. creates a sandbox named `runner-` and the repository or org (`--name` to choose), of size `small` (`--size` for `default`, `large` or `xlarge`), or reuses the sandbox of that name;
2. keeps it awake, so it never goes to [standby](/docs/sandboxes/lifecycle/#standby) and is there when jobs come;
3. installs the pinned release of actions/runner after checking it against the SHA-256 GitHub publishes;
4. registers it with the repository or organization and starts it as a systemd service.

The runner's labels are `self-hosted`, `Linux`, `X64`, `pols` and any `--label` you add (repeatable). It does not get `pols-<size>`, which belongs to the per-job runners. A workflow uses it with:

```yaml
runs-on: [self-hosted, pols]
```

Running `pols runner add` again is harmless: it starts the runner if needed, and registers it again in place when its name or labels changed. The runner updates itself.

### GitHub credentials

Your GitHub credentials stay on your machine. The CLI asks GitHub for a short-lived registration token with `--token`, else the login of `gh`, else `GITHUB_TOKEN`, and passes only that token into the sandbox, in the environment, never on a command line. The token needs admin rights on the repository, or `admin:org` for `--org`.

### Public repositories

A repository GitHub says is public is refused unless you pass `--allow-public`: pull requests from forks may run code on a persistent runner. Organization runners are not checked.

## Listing and removing runners

`pols runner ls` lists the runners in your org's running sandboxes that are kept awake.

`pols runner rm SANDBOX` stops the runner's service, deregisters it from GitHub with a short-lived removal token, and turns keep-awake off so the sandbox may go to standby again. With `--delete-sandbox`, it deletes the sandbox too. `--token` works as for `add`.

## Cost

A sandbox kept awake is billed as running all the time, at the [rate card](/docs/account/orgs/#usage-and-billing), whether or not jobs run. `pols runner add` prints what keeping it awake costs a month for its RAM. Its sandbox counts against your org's [sandbox quotas](/docs/getting-started/limits/#quotas) like any other.

All flags are in the [CLI reference](/docs/reference/cli/runner/).
