> ## Documentation Index
> Fetch the complete documentation index at: https://axe-engine.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# gVisor

> Run axed under gVisor's runsc, without delegated cgroups, and keep processes running across checkpoint and restore.

This page covers running axed inside a gVisor sandbox: how to start it, what changes without cgroups, and what happens across `runsc checkpoint` and `runsc restore`. It was tested on gVisor's systrap platform, which needs no KVM.

## Run axed under runsc

axed runs under `runsc` like any other container entrypoint. If your container runtime is configured with `runsc` as a runtime (for example Docker's `--runtime=runsc`, or a Kubernetes `RuntimeClass`), run the AXE image as you would under runc, and clients reach axed over TCP the same way. See [Containers and hosts](https://axe-engine.mintlify.site/deploy/containers.md) for the options that apply to any container.

To drive `runsc` directly with an OCI bundle, which is how checkpoint and restore were tested:

1. Create a bundle directory, for example `/bundle`, with the root filesystem in `/bundle/rootfs`. It needs the `axed` and `axectl` binaries in `/usr/local/bin` (see [Installation](https://axe-engine.mintlify.site/installation.md#the-static-binaries)), and the programs you will run. axed creates its workspace (`/ws` below) at startup if it does not exist. An exported `debian:bookworm-slim` filesystem works as the base.

2. In the bundle directory, generate `config.json` with axed as the entrypoint:

   ```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
   runsc spec -- /usr/local/bin/axed --root-dir /ws --cgroups off --log-format text
   ```

3. Edit `config.json`: set `"terminal": false`, since axed runs detached, and set `"readonly": false` on the root so the workspace is writable.

4. Start the sandbox detached. The tested setup passed `--platform=systrap --network=none --ignore-cgroups` to every `runsc` command, including the ones below.

   ```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
   runsc run -detach -bundle /bundle axe
   ```

With `--network=none`, nothing outside the sandbox can reach axed's ports, so run `axectl` inside the sandbox:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
runsc exec axe /usr/local/bin/axectl info
```

To reach axed from outside, give the sandbox a network the way your runtime normally does, and keep axed listening on an address clients can reach (the default `--listen-host 0.0.0.0`).

## No delegated cgroups

gVisor offers no delegated cgroup hierarchy, so axed runs without cgroups. With the default `--cgroups auto` it logs `cgroups unavailable; using process groups and rlimits` and continues. `--cgroups off` skips the attempt. Do not use `--cgroups required`, because axed then refuses to start.

Without cgroups:

* Killing a process kills its process group and every descendant axed can find through `/proc`.
* Memory limits map to `RLIMIT_AS`, which applies to each process separately. Task limits map to `RLIMIT_NPROC`, which counts every process of the user. Neither limits a process tree as a whole.
* CPU limits and `System.Freeze` are refused.

Let gVisor and the container runtime enforce sandbox-wide CPU and memory limits. See [Containers and hosts](https://axe-engine.mintlify.site/deploy/containers.md#cgroups) for the cgroup modes.

## Checkpoint and restore

`runsc checkpoint` freezes the whole sandbox to an image, and `runsc restore` brings it back. axed needs no hooks for this:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
runsc checkpoint --image-path /ck axe
runsc delete -force axe
# later
runsc restore -detach -image-path /ck -bundle /bundle axe
```

After restore:

* Detached processes are still running, and their output replays intact from offset 0.
* The process table and its `instance_id` survive, because they are in memory.
* axed records the resume, and `axectl info` shows `generation 1`. gVisor hides suspended time from `CLOCK_MONOTONIC` but not from `CLOCK_BOOTTIME`, and axed detects that gap.
* Timeouts count running time only. A process with a 20-second timeout, frozen for 15 seconds, times out after about 20 seconds of running time, not 5.

Client connections end at checkpoint. Clients reconnect after restore and continue from the last offset they saw. See [Snapshots](https://axe-engine.mintlify.site/snapshots.md) for how detection works.

## What was tested

Under `runsc` on the systrap platform:

* The engine's own test binaries run unchanged.
* axed end to end: detach and offset replay, PTYs, running-time timeouts, uploads, directory watching, path confinement and tree kill.
* Checkpoint and restore with axed as PID 1, a detached process with a 20-second timeout, and the sandbox frozen for 15 seconds, with each result listed above.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.