Sandboxes
Run the agent and your checks in a Linux VM built from a Dockerfile in your repository. Step by step for Docker Sandboxes and Apple Container.
The image holds your agent and your test tools. The sandbox is the named VM Yokai creates from that image and reuses across runs. Both are defined by files in your repository, so anyone can build the same environment. Sandbox mode explains how the pieces connect.
Prepare the image
Choose a backend:
- Docker Sandboxes: Docker Desktop running and the
sbxCLI installed. Runsbx loginonce. - Apple Container: macOS 26 on Apple silicon. Start the service with
container system start.
Open setup at the repository root:
yokai setup
In Configuration, set Environment (e) to the backend and give the image a tag (i). In the Environment step, Yokai proposes .koi/Dockerfile.sandbox if it is missing. Read it. It must install each agent you configured and every tool your sensors call. Then choose Approve and build: Yokai saves the file, builds the image and replaces the named sandbox.
The image's final user must be able to write where the launcher copies yokai. Docker templates use the agent user and /home/agent/.local/bin. Apple images normally stay root and use /usr/local/bin.
Setup saves the choice:
# .koi/yokai.yml
sandbox:
enabled: true
backend: docker # or apple
image: daylist-sandbox
# name: yokai-daylist default: yokai-<repository folder>
# memory: 8g Apple only; default 8 GB
# cpus: 4 Apple only; default 4
The sandbox recipes have example Dockerfiles.
Linux binaries
The launcher copies a Linux yokai of the same version as your host binary into the VM. You do not need to fetch it. It looks in this order:
YOKAI_LINUX_BINARY, an explicit path. It wins over everything else. Use it for dev builds or an offline mirror.- A cached copy for this version:
${KOI_DATA_DIR:-~/.local/share/koi}/bin/yokai-linux-<arch>-v<version>. - A download of
yokai-<arch>-unknown-linux-musl.tar.xzfromhttps://github.com/getkoi/koi/releases/download/v<version>/. The launcher checks it against the published.sha256, refuses a mismatch, and caches it under the name above. - An older local build at
${KOI_DATA_DIR:-~/.local/share/koi}/bin/yokai-linux-<arch>, used only when the download fails.
<arch> is the host's: aarch64 on Apple silicon, x86_64 on Intel. The first sandbox launch of a release therefore needs network access to GitHub. yokai doctor shows which copy the next launch will use, without touching the network.
If nothing works, for example an unreleased dev build with no network, build the file once from a koi clone with scripts/build-linux-artifacts.sh, or point YOKAI_LINUX_BINARY at a Linux yokai. yokai --host runs without the sandbox.
Start the sandbox
To build the image by hand instead of through setup:
# Docker Sandboxes
docker build -f .koi/Dockerfile.sandbox -t daylist-sandbox .
# Apple Container
container build -f .koi/Dockerfile.sandbox -t daylist-sandbox .
Use the same tag as sandbox.image. Then run one phase:
yokai setup --once
Review the sensors in this environment and choose Start run. Yokai creates or reuses the named sandbox, copies the Linux binary in, runs .koi/sandbox-setup.sh once if it exists, and starts the supervisor inside. The repository is mounted read-write at the same path as on the host, so changes land in your checkout. The VM has network access.
Sign the agent in
- Docker Sandboxes can pass host credentials through
sbx secretor its proxy. - Apple Container needs a login inside the VM. For OpenCode:
container exec -it yokai-daylist opencode, then/connect. Recreating the VM loses that login.
yokai doctor --probe checks the configured agents. Its live login check runs on the host, so a passing host check does not prove the VM is signed in.
Update the sandbox
Recreate the sandbox after changing the image, the agent, the test tools or the Apple VM size. Rebuilding a tag does not change a VM that already exists. Setup's Approve and build does the replacement. By hand: sbx rm yokai-daylist for Docker, container stop yokai-daylist and container rm yokai-daylist for Apple. Then launch again, sign in again if needed, and rerun the sensor smoke review.
Use .koi/sandbox-setup.sh for one-time setup the image cannot do. The launcher records that it ran under /home/agent/.local/share/koi/ (Docker) or /var/lib/koi/ (Apple). Keep agents and test tools in the Dockerfile.
Run on the host
For one launch on your own machine:
yokai --host --once
The next launch uses the sandbox again. Set sandbox.enabled: false to make the host the default. Either way, the sensors need a smoke review in the environment they run in.
What can go wrong
| Symptom | Fix |
|---|---|
failed to connect to the docker API |
Start Docker Desktop |
sbx or container not found |
Install the backend's CLI, or use --host |
| Agent not found inside the VM | Install it in the Dockerfile, rebuild, recreate |
chmod … /usr/local/bin/yokai: Operation not permitted (Apple) |
End the Dockerfile as root, rebuild, recreate |
no release asset at … or could not download … |
Check the network, or set YOKAI_LINUX_BINARY; see Linux binaries |
| Tools unchanged after editing the Dockerfile | Recreate the sandbox |
| Out of memory on Apple | Raise memory and cpus, then recreate; limits are fixed at creation |
More in Run troubleshooting.