Skip to main content
A service manager starts the runner at boot, restarts it after a crash and lets it update itself. outerlayer runner init sets the service up on the machine where you run it. See Set up your first host. This page is for the person who operates that runner afterward. The runner keeps its files beside its config file. Where that file is depends on the account: The commands on this page use the paths for an account of its own. On your own account, add --config ~/.outerlayer-runner/config.json to each outerlayer runner command. Also use ~/.outerlayer-runner/ in place of ~/.outerlayer/ in each runner path.

What the service sets

To set the service up again, run:
On Linux, the command writes one systemd unit at /etc/systemd/system/outerlayer-runner.service, then enables and starts it. It asks for sudo, and names each sudo command before it runs. The unit runs as the account that ran the command. Pass --user <account> to name another. The command refuses on a Linux host without systemd, and for hooks that are your own executables. For those hosts, --print writes the unit to standard output and sets up nothing, so you can edit it. A stop of the service waits up to runner.timeLimitMinutes plus ten minutes for running builds. Every flag is in outerlayer runner install.

The files the service reads

The service reads two files beside the config file. Only the runner’s account can read them.
  • claude.env holds Claude’s credential: CLAUDE_CODE_OAUTH_TOKEN=<token> or ANTHROPIC_API_KEY=<key>. Without a credential, the runner claims nothing.
  • runner.env holds every secret that a destination reads and every value that build.variables passes in.
The service reads both files only when it starts. Restart it after you edit either: sudo systemctl restart outerlayer-runner. On systemd 247 or later, no process that the runner starts inherits the Claude credential. On older systemd it stays in the service’s environment, and the install prints a line that says so. Run systemctl --version to see your version.

Replace the Claude credential

  1. Create a new token with claude setup-token, or use a new Anthropic API key.
  2. Write one line in claude.env, in place of the old line: CLAUDE_CODE_OAUTH_TOKEN=<token> or ANTHROPIC_API_KEY=<key>.
  3. Restart the service with sudo systemctl restart outerlayer-runner. Start and stop the runner says what a restart does to running builds.

Keep the host awake

A build fails when its host sleeps. A sleeping host stops the runner, so the runner stops renewing the build’s claim, and the claim runs out. On a Mac, caffeinate changes no energy setting, and it ends with the runner. It cannot stop a sleep that you start, or a laptop that sleeps when you close its lid. To see it while a build runs, run pmset -g assertions. To turn it off, set runner.keepAwake to false in the config file.

Re-run the service

The runner reads the config file again on every poll, so most edits need nothing else. Run outerlayer runner install --service again after a change to one of these:
  • runner.timeLimitMinutes
  • runner.concurrency, with builtin:vm hooks
  • runner.build.imageBuild
  • the hooks
  • the config file’s path, or the account
When the unit is current, the command changes nothing and says so. When the unit changes, the command restarts the service only while no build runs. Otherwise the new unit applies at the next restart. The command does not change a unit at that path that it did not write. Pass --replace to replace it. Restart the service after you add its account to a group, such as kvm. The service reads the account’s groups only when it starts.

The account the runner runs as

To run the runner under an account of its own:
  1. Create the account with your system’s tools.
  2. Install Node.js 22.15 or later where the account can run it.
  3. Log in as the account, and install the CLI: npm install -g @outerlayer/cli.
  4. Create a runner key with the Runner preset, as Give the runner its key shows.
  5. Save the key with outerlayer login.
  6. Follow Set up your first host from Give the runner Claude’s credential, or from Build with Codex for a runner that builds only with Codex. Leave out --config in each command.
For a runner that already exists, an administrator can run outerlayer runner install --service --user <account>. See Several accounts on one machine. The runner never answers a prompt. A build that prompts waits until the idle limit ends it with the outcome idle. So under the service’s account:
  • Built-in hooks use only the credentials in the files beside the config file: the agent’s own file (claude.env, opencode.env or codex.env) and runner.env. They do not use a claude or codex login made in a terminal.
  • Builds in containers and microVMs need no git login. They use the GitHub App.
  • Hooks of your own need a git login that fetches with no prompt. Use a deploy key, a credential helper with a stored token, or an SSH agent that the service can reach. outerlayer runner image on a private repository needs one too.
  • With hooks of your own, the agent must already be logged in under this account.
Hooks and the command find the runner’s own CLI first on PATH.

Memory limits

Every build has a memory limit of its own, runner.build.memory, and the runner never runs more than runner.concurrency builds. So the builds together use at most concurrency times build.memory.
Example: a 32 GiB host with concurrency 2 and build.memory 8 GiB. 2 GiB is kept for the runner and the system, the two builds take 16 GiB, and 14 GiB is left, so the builds fit. Zoomed in, one microVM build runs up to build.memory. Above build.memory plus 256 MiB the kernel slows its writes, and above build.memory plus 1 GiB the microVM is killed and the build ends with the outcome failed.Example: a 32 GiB host with concurrency 2 and build.memory 8 GiB. 2 GiB is kept for the runner and the system, the two builds take 16 GiB, and 14 GiB is left, so the builds fit. Zoomed in, one microVM build runs up to build.memory. Above build.memory plus 256 MiB the kernel slows its writes, and above build.memory plus 1 GiB the microVM is killed and the build ends with the outcome failed.
Setup refuses builds that cannot fit. It compares concurrency times build.memory with the memory the runner can use, less 2 GiB. That memory is the host’s on Linux, the VM’s on a Mac and the distribution’s on WSL2. With the defaults (build.memory of 8g, concurrency of 1), the machine needs 10 GiB. A runner whose builds do not fit claims nothing, and its entry in the factory says why. At the limit:
  • A container build, and each of the runner’s image builds, is limited to build.memory.
  • A microVM build slows above build.memory plus 256 MiB. Above build.memory plus 1 GiB, the kernel kills the microVM.
  • A killed build ends with the outcome failed, and its reason says that it ran out of memory. The other builds and the runner carry on. See When a build runs out of memory.
Under a unit that you wrote yourself, or on cgroup v1, a microVM build has no limit of its own. outerlayer doctor warns.

Disk fit

A build’s disk can grow to runner.build.disk, 40g by default. Before it claims work, the runner counts how many builds of that size fit on the host. It runs no more builds than fit, and no more than runner.concurrency. The count uses these figures:
  • The free space on the file system. For builtin:vm, that is the file system of the runner’s folder. For builtin:container, it is the file system that holds Docker’s volumes.
  • The space one build can hold: build.disk, plus the build’s root disk for builtin:vm.
  • For builtin:vm, room for each repository’s image-build cache to grow to runner.build.cacheDisk, 40g by default.
When not even one build fits, the runner claims nothing. Its entry in the factory names the space one build can hold and the space the runner counts. To fix it, do one of these:
  • Lower runner.build.disk or runner.build.cacheDisk.
  • Give the host more disk.
  • In the runner image, set OUTERLAYER_CONCURRENCY in the env file and recreate the container.
outerlayer doctor reports the same count as its Build disk fit check. It warns when fewer than runner.concurrency builds fit, and fails when none fit. The count assumes that a build uses its whole build.disk. If your builds use much less, lower build.disk. For each microVM build, the runner log has a build disk peak line with the most disk the build used. This check differs from minFreeDisk, in Housekeeping. minFreeDisk holds new work but does not protect builds that already run.

Image builds

The runner builds a repository’s build image before the repository’s first build. It builds the image again when the recipe or the CLI changes. So the first build of a repository is slow. Where the image builds depends on the hooks: What an image build can reach is in What an image build reaches. For the builder microVM:
  • The cache disk needs about twice the image’s size. The universal image needs about 30 GB, so the default of 40g holds it.
  • A change to runner.build.cacheDisk gives the next image build a new, empty cache disk.
  • To pull from a private registry on your own network, set runner.build.imageBuild to host.
A host that builds images in its own Docker needs:
  • Docker’s Buildx plugin, version 0.18 or later. It is docker-buildx-plugin in Docker’s apt repository and docker-buildx in Ubuntu’s own packages.
  • Access to Docker Hub, to pull the BuildKit image once.
  • A proxy, if any, that the builder can reach. The runner passes its own HTTP_PROXY, HTTPS_PROXY and NO_PROXY to the builder. The builder cannot reach a proxy on the host’s loopback address. A password in a proxy address shows in the host’s process list, so use a proxy that needs none.
Without a usable Buildx, such a runner claims no work, and outerlayer doctor fails its “Image build limit” check. See When the Image build limit check fails. On such a host, a change to runner.build.memory replaces the runner’s builder, which clears its cache. An image build that reaches the memory limit ends failed at provision. See When an image build runs out of memory.

The outerlayer command

For the runner of the default config, ~/.outerlayer/config.json, outerlayer runner install writes ~/.local/bin/outerlayer. It runs the CLI version that the runner runs, also after the runner updates itself. So outerlayer runner status, doctor and logs in a shell always match the runner. A runner with another config, such as ~/.outerlayer-runner/config.json on your own account, does not write the command. Your own outerlayer stays first on PATH. Give that runner’s commands its --config. The runner never edits a shell startup file. When ~/.local/bin is not on PATH, or another outerlayer comes first, the command prints the line to add:
outerlayer doctor shows the same as its “outerlayer on PATH” check. The command does not change a file at that path that the runner did not write. Run outerlayer runner install --replace to replace it.

Start and stop the runner

A stop or restart of the service makes the runner wait for its running builds. A build keeps running without its runner in these cases:
  • A container build keeps running when its runner restarts for an update, or crashes.
  • A microVM build keeps running through a service stop, a restart, an update and a crash, when it can outlive its runner.
  • A sandbox build keeps running at the provider when its runner crashes, or restarts for an update to a version that says it adopts sandbox builds.
A build carries on through a restart only while its command runs. The runner waits for a build that is in setup, in its judge stage or in cleanup. The runner that starts next takes over each build that still runs. A build whose runner never comes back loses its claim and stops. The full table is in What ends or keeps a build.

Let a restart through

A runner that waits for its running builds can hold a restart for hours. To let the restart through, stop the build that the runner waits on.
  1. Find the build. The item page says <runner> is draining. GET /v1/hosts and the MCP tool list_hosts show a draining runner and the items it waits on.
  2. Stop it. On the item page, select Stop build and confirm. Or run outerlayer work stop --item <n>.
The runner ends the build on its next heartbeat, with the outcome stopped. The restart goes ahead when the last build has ended. The stopped build’s request is used up, so the item is not built again until someone asks for another build. See outerlayer work stop.

A microVM build outlives its runner

A microVM build keeps running while its runner restarts only when all of these are true:
  • The microVM helper runs the build.
  • The host runs systemd 254 or later.
  • The service’s unit came from a current release. Run outerlayer runner install --service --replace to write one.
  • The runner started under that unit. After you replace the unit, restart the service once, while no build runs.
  • The unit has room for the build’s sockets. The unit is sized from runner.concurrency, so run outerlayer runner install --service again after you raise it.
Otherwise the build ends with its runner, and an update waits for every build to finish. outerlayer doctor warns about the first four on its MicroVM jailer line. As such a build starts, the runner log says “this build ends with its runner” and gives the reason. A microVM build that stopped while no runner managed it ends interrupted. A reboot of the host is one example.

The host key

A runner key works only from the host that first used it. On its first run, the runner makes a host key at runner/host-key.pem beside its config file, readable only by its account. The private half never leaves the machine. The runner’s first claim binds the host key to the runner key, and the organization audit log records it. From then on, OuterLayer refuses that runner key unless the host key signed the request. So a leaked runner key is useless without its host key. Keep the host’s clock in sync. Each signature must be within five minutes of OuterLayer’s clock. When a signature is refused, see When the gateway refuses a signature. Settings → API keys shows each bound key’s host key fingerprint and when it was bound. outerlayer doctor says whether the runner key is bound to this host.

Moving a runner to a new host

To move a runner key to a new machine, or after you delete host-key.pem:
  1. Ask a member who may update API keys to open Settings → API keys and choose Clear host key on the runner key.
  2. Start the runner on the new host at once. Its first claim binds the new host key, and anyone else who holds the key could bind it first.
Until step 1, the runner on the new host is refused with runner_key_signature_invalid, and the runner on the old host keeps working. The organization audit log records the change as runner_key_binding_cleared.

Several factories, one machine

One config file is one factory. To serve two factories from one host, run two runners. Give each runner these:
  • A config file in a directory of its own, such as /etc/outerlayer/acme/config.json. The runner keeps its host key and its builds in runner/ beside the config file.
  • A runner key of its own. Each directory has its own host key, so a key that the first runner bound is refused from the second.
  • A name of its own, in runner.name.
  • A unit of its own. Pass --unit-name <name> and --config <path> to runner init, runner install --service and runner uninstall --service.
By default, each runner checks its builds against all of the machine’s memory. Size the two runners’ concurrency and build.memory together, or give each runner a limit. Hook scripts that the runners share must read OUTERLAYER_URL and OUTERLAYER_APP_ID, not assume one factory. outerlayer runner check, runner status and doctor report on the runner whose config file you give them.

Several accounts on one machine

To serve customers that must not reach each other, give each runner its own Linux account. As an administrator, run this for each one:
Each runner then has its own unit and its own microVM helper. The builds of one runner share nothing with the builds of another:
  • Build users. A build of one runner never runs as the user of another runner’s build.
  • Files. Each runner’s config file, claude.env and host key are readable by its account only.
  • Docker. A runner that needs no Docker does not need the docker group, which is equal to root on the machine.
Do not give an account the docker group on a machine that other customers share. Each runner’s disk check is exact only when each account has a file system of its own.

A runner that needs no Docker

A runner needs no Docker on the host when both of these are true:
  • Its hooks are builtin:vm.
  • runner.build.imageBuild is not host.
The host then needs mke2fs, which is in the e2fsprogs package. outerlayer runner init, runner check and doctor accept a machine with no Docker.

Limit the memory and CPU of a runner’s builds

To keep all of one runner’s builds within a memory limit and a CPU limit, pass the limits when you install the service:
The runner then compares concurrency times build.memory with that memory limit, not with the machine’s memory. The limit covers builds only, so leave the machine the memory that its own services need. The options need builtin:vm hooks.

Keep the runner up to date

A service runner updates itself to the named version. It never moves to a lower version. It runs a new version only after it checks the package. See How a runner updates itself. A runner that was not installed with runner install cannot update itself. It logs that it cannot, and it keeps taking work. Run outerlayer runner install --service to fix it. If the command says that the unit differs, run it again with --replace.

The support window

OuterLayer refuses claims from a runner that is too far behind. A runner may run a version for 30 days after OuterLayer names a newer one. Those 30 days are the support window. Two cases have other dates:
  • A raised minimum version. OuterLayer raises the minimum when an older runner has a known fault. The new minimum takes effect 7 days later. An urgent minimum takes effect at once, with no notice.
  • A factory that holds its runners. In a factory set to Paused or Hold at a version, only the minimum version applies.
A refused runner claims nothing, and it keeps polling. Its log names the lowest version that OuterLayer accepts. The build request stays unused, so the item starts when a runner with an accepted version takes it. The refusal is a 426 with the code runner_version_unsupported. A runner that updates itself stays inside the window. For any other runner, you learn that an update is due in these places:
  • Email. The factory’s owners and admins get two emails about a runner: one 7 days before OuterLayer refuses it, and one when it does.
  • The factory’s Settings → Runners page. It lists each runner with its version and status. For a runner that is behind, it shows the date OuterLayer starts to refuse it and the version to update to.
  • The Work page. An item that only a refused runner takes reads Not picked up, with the caption “runner needs an update”.
Then follow Update a runner.

When a build carries on through an update

A service runner restarts for an update at once when every running build carries on through the restart. Start and stop the runner says which builds do. Otherwise the runner keeps taking work, and it updates the first time no build runs. A sandbox build carries on only when the new version says it adopts sandbox builds. The runner asks the new version before it restarts. A version that gives no answer counts as one that does not adopt them. The runner then waits, and outerlayer runner status names the build with the reason is a sandbox build, which the new version does not say it adopts.

When the runner holds work for an update

The runner stops taking new work for an update in two cases only:
  • OuterLayer refuses its claims because its version is too old.
  • The update waited longer than runner.update.maxWaitHours, 6 hours by default.
outerlayer runner status shows the builds that an update waits for.

Update the microVM helper

The runner cannot update the microVM helper itself, because the helper needs root. When the runner’s log or the MicroVM jailer line of outerlayer doctor says that the helper needs reinstalling, run:
Until then, the runner builds without the helper.

Upgrade by hand

A runner with updates off, or one that cannot update itself, is upgraded by hand. The commands are in Update a runner. On a service runner:
  • Do not restart the service yourself. The runner sees the new version on its next poll. It restarts when its running builds allow it, and it takes no new work while it waits.
  • A version that fails its checks at its first start is rolled back. The runner goes back to the previous version and records rolled_back.
  • An older CLI is refused. runner install installs a CLI older than the runner’s version only with --allow-downgrade.
A runner started by hand with outerlayer runner start does not restart itself. Run outerlayer runner stop, then outerlayer runner start.

Pausing or holding updates for a factory

An owner or admin can stop or limit updates on every runner of a factory at once. Open the factory’s Settings → Runners page and change Runner updates:
  • Automatic, the default: runners update to the named version.
  • Paused: no runner updates.
  • Hold at a version: runners below that version update to it, and none moves past it. The version is no higher than the named version.
The setting takes effect on each runner’s next heartbeat. A runner never moves down, so a held version lower than a runner’s version leaves that runner where it is. A raised minimum version applies in every mode. The warning email and the Runners page then tell the owner to update the runner to that minimum. The API takes the same setting as runner_updates on PATCH /v1/apps/{appId}, with the values follow, paused and pinned. See the API reference.

Housekeeping

A runner with built-in hooks removes what its own builds leave behind, so it needs no cleanup script. It does this when it starts and then once an hour. Each removal is one line in the runner log. The runner removes:
  • Finished builds. Job directories and kept sessions go after jobsKeepDays, 30 days by default.
  • Containers, volumes and images of its own builds that no unfinished build uses.
  • The cache of its own image builder, down to buildCacheMax, 20g by default.
  • Disks kept for work items, after workspaceKeepDays, 7 days by default. Above workspaceMax, 40g by default, the oldest go first. See What an agent job starts from.
  • Saved states that are 7 days old. Above savedStateMax, 20g by default, the oldest go first. See The saved state.
The runner never removes anything that it did not make. It never touches another runner’s builds on the same Docker daemon, or anything that belongs to an unfinished build. It leaves Docker’s default builder alone: to clear that, run docker builder prune. A runner whose hooks are its own executables gets no cleanup. Its hooks own what they create.

Free disk

Before it claims work, every runner checks the free space on the file system that holds its folder. Below minFreeDisk it claims nothing, and it logs why once. The default is the value of runner.build.disk. Before the runner holds off, it removes its oldest kept disks, and then its oldest saved states. It claims again when there is room, with no restart. See When the runner holds off for disk. outerlayer runner status shows when housekeeping last ran and what it freed. outerlayer doctor warns when free disk is below the minimum. Set these keys under runner.housekeeping. Each one is in The config file.

Uninstall the runner

On a Mac, follow Remove the runner instead.
  1. Stop the service and remove its unit. To end running builds without a wait, run outerlayer runner stop --now first.
    For a second runner, add its --unit-name and --config. On Windows, see Remove the runner for the scheduled task.
  2. Read the label and the builder name of the runner’s Docker objects. Skip steps 2 and 3 on a machine with no Docker.
    The file holds a label and a builder. If the file is missing, docker buildx ls lists the builder, named outerlayer- and the label.
  3. Remove the images, volumes and image builder of this runner. Docker objects of another runner on the machine stay.
  4. As the runner’s account, delete the runner’s files:
    • On your own account: ~/.outerlayer-runner/. Do not delete ~/.outerlayer/config.json, because it holds your own login.
    • Under an account of its own: runner/, runner.env and claude.env in ~/.outerlayer/. Delete config.json there too, or only its runner and apiKey entries.
    • ~/.local/bin/outerlayer, if the runner wrote it.
    • ~/.outerlayer/cli, if outerlayer init made it.
  5. Run npm uninstall -g @outerlayer/cli, if nothing else uses it.
  6. Delete the runner key in Settings → API keys. OuterLayer refuses the key within about five minutes.