Sandbox images

On this page
  1. The default image
  2. How hosts get it
  3. Its layout
  4. Your own image
  5. An image from another base
  6. Building it from the repository
  7. Which images a host runs
  8. What an image needs
  9. What fctl writes into a sandbox

With the Apple container and Docker drivers, each session runs in a container made from an image. This page describes the default image and how hosts get it, how a project uses an image of its own (built on the default one, or on another base such as Ubuntu) or builds one from its repository, which images a host runs, and what an image needs.

The default image

ghcr.io/hyperstructure/sandbox is built from hyperstructure/sandbox, a public repository whose README lists the versions: Debian 13 (trixie) with git, the GitHub CLI, build tools, Python and uv, Rust, Node.js, TypeScript, Bun, Playwright with its browsers, Claude Code and fctl. It is published for arm64 (Apple silicon) and amd64.

Tag Image
0.5.0 fctl 0.5.0's. Hosts of that version use it.
0.5 The newest 0.5 release's.
latest The newest release's.

The sandbox repository's Image workflow builds every tag from its main branch, with that release of fctl and the newest Claude Code. fctl's Release workflow starts it for each release, so a release's image follows minutes after the release is published. fctl turns off Claude Code's auto-updater, so an image's Claude Code is as old as the image: every day, the workflow rebuilds the latest release's image when Claude Code has a newer release, and once the image is a week old, for Debian's updates. A change to the image rebuilds it too. A rebuild moves the tags; to pin one build, add its digest: ghcr.io/hyperstructure/sandbox:0.5.0@sha256:….

Its labels say what is inside:

Label Value
org.opencontainers.image.version, sh.fctl.version fctl's version
sh.fctl.claude-code.version Claude Code's version
org.opencontainers.image.revision the commit of hyperstructure/sandbox it was built from; images built elsewhere have none
org.opencontainers.image.created when it was built
docker image inspect ghcr.io/hyperstructure/sandbox:0.5.0 \
  --format '{{ index .Config.Labels "sh.fctl.claude-code.version" }}'

How hosts get it

A host whose host.toml sets no image uses the default image of its own version, so a host that updates, by itself or with fctl self update, moves its new sessions to the new version's image. The host pulls the image in the background when it starts, and a session that starts before it has the image waits for that pull, or pulls it itself when none is under way: one pull of an image at a time. A session's log says every 30 seconds how far along the pull is (with Apple's container, its percentage and speed; with Docker, its layers), and how long it took. A pull whose connection to the registry breaks off partway is tried again, three times in all, as is one that fctl host image pull shows; sessions that waited for a pull that failed fail with it. When the image can't be pulled, as in the minutes after a release before its image is published, the host pulls latest instead, and sessions start from it and say so in their log; not when the image's download broke off, as latest's, of mostly the same layers, would too, unless latest is already on the runner. The first session after the version's image is published pulls it.

The host pulls its tag again when it starts and every 6 hours, so new sessions start from the newest build of it, with the newest Claude Code. Sessions don't wait for that: they start from the build that is there, and a tag that hasn't changed costs one request to ghcr.io. fctl host image pull pulls it now. While the version's image can't be pulled, it pulls latest instead, and says so: not when the image's download broke off or the runtime didn't answer, as latest's pull would fail the same way.

Its layout

Images built FROM the default image can rely on its layout, which stays the same from version to version. The sandbox repository's check.sh checks every build for it:

In projects that share package caches, the Docker, Apple container and Firecracker drivers mount the project's caches at /var/cache/fctl, over whatever an image has there (Firecracker's VMs over 9P, as the image's user's files), and fctl-agent points the package managers there, for the setup script and for Claude: npm_config_cache, pnpm_config_store_dir and pnpm_config_cache_dir (pnpm 11; pnpm 9 and 10 get theirs in ~/.config/pnpm/rc), COREPACK_HOME, YARN_CACHE_FOLDER and YARN_GLOBAL_FOLDER, BUN_INSTALL_CACHE_DIR, UV_CACHE_DIR, PIP_CACHE_DIR, GOMODCACHE and PLAYWRIGHT_BROWSERS_PATH, with FCTL_CACHE_DIR for the directory itself. Cargo keeps its downloads beside its tools, so ~/.cargo/registry, ~/.cargo/git and their lock files become links into the caches. What an image sets stays: its own variables, a ~/.cargo/registry it comes with, and browsers in ~/.cache/ms-playwright, which the default image comes with: Playwright keeps other versions' browsers there too, so they download in each sandbox rather than once into the caches. With Docker, the host gives the caches to the image's user, agent or another; a host that runs nothing as root in its sandboxes (agent_as_root = false) leaves that to Docker, which gives a new volume the owner of the image's /var/cache/fctl (agent's in the default image). fctl-agent checks it can write to them, and without that, the session's package managers keep their own.

An image that installs something as root switches back to agent at the end:

FROM ghcr.io/hyperstructure/sandbox:0.14
USER root
RUN apt-get update \
  && apt-get install -y --no-install-recommends postgresql-client \
  && rm -rf /var/lib/apt/lists/*
USER agent

Your own image

When sessions need tools the default image lacks, such as .NET or a company's CLIs, give the project an image that has them. A setup script would install them in every session instead. An image you already have, on Ubuntu say, works too once fctl and Claude Code are in it (An image from another base). This example adds the .NET 8 SDK. .NET needs ICU, which Debian has, and the SDK goes into agent's home, like Rust. The PATH is set twice: ENV for Claude and the commands it runs, and /etc/profile.d for login shells, which setup scripts run in:

FROM ghcr.io/hyperstructure/sandbox:0.14

USER root
RUN apt-get update \
  && apt-get install -y --no-install-recommends libicu76 \
  && rm -rf /var/lib/apt/lists/* \
  && printf '%s\n' 'export DOTNET_ROOT="$HOME/.dotnet"' \
    'PATH="$HOME/.dotnet:$HOME/.dotnet/tools:$PATH"' > /etc/profile.d/dotnet.sh
USER agent

RUN curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh \
  && bash /tmp/dotnet-install.sh --channel 8.0 --install-dir /home/agent/.dotnet \
  && rm /tmp/dotnet-install.sh
ENV DOTNET_ROOT=/home/agent/.dotnet \
  DOTNET_CLI_TELEMETRY_OPTOUT=1 \
  PATH=/home/agent/.dotnet:/home/agent/.dotnet/tools:$PATH

Of the image's variables, Claude gets the PATH and the locale but not the others (An image from another base): dotnet finds its SDK beside itself, and for Claude's commands, DOTNET_ROOT and DOTNET_CLI_TELEMETRY_OPTOUT go in the project's variables too.

  1. Build it for both architectures and push it to a registry: Apple silicon runners run arm64 images, most others amd64.

    docker buildx build --platform linux/arm64,linux/amd64 \
      -t ghcr.io/acme/dotnet-agent:1 --push .
  2. Choose it for the project. In Settings → Sandbox → Image, pick "An image from a registry" and enter ghcr.io/acme/dotnet-agent:1. From the CLI:

    fctl projects set -p my-app --image ghcr.io/acme/dotnet-agent:1
    fctl projects set -p my-app --image ""     # back to each runner's own

    Maintainers and owners can change it. Sessions that start or resume afterwards in a new sandbox use it; a sandbox that exists keeps the image it was made from.

  3. Hosts run it if their owners allow it. A host that lists allowed_images runs only the images on its list (Which images a host runs); one that lists none runs any.

  4. Private registries. Hosts pull images with their own login to the registry: run docker login ghcr.io (with Apple container, container registry login ghcr.io) on each runner, as the user its host service runs as. fctl sends no registry credentials. For GHCR, a token with read:packages is enough. Firecracker hosts read the credentials docker login keeps in ~/.docker/config.json (but not those of a credential helper), so docker login there needs Docker's CLI only.

Lima runners don't use images: their sessions run in a clone of the VM fctl host image build prepared. The process driver uses none either.

An image from another base

An image doesn't have to start from the default one. One your company already has, on Ubuntu with its own toolchains say, runs sessions once it has what fctl needs (What an image needs): fctl, Claude Code, git, gh, bash and a user other than root. fctl-agent, the supervisor, isn't one of them: the host copies its own into each sandbox when it starts a session there, of the host's version, so an image has none to install or update.

This Dockerfile makes Ubuntu 24.04 into a sandbox image: add your packages and steps to it, or its steps to your Dockerfile. The sandbox repository keeps it, as examples/ubuntu/Dockerfile, and builds and checks it for both architectures.

FROM ubuntu:24.04

# A download piped into a shell fails the step when it fails.
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

# What fctl needs: bash, git, curl and CA certificates (for the installers,
# and git over HTTPS), and the GitHub CLI from GitHub's repository. sudo lets
# the agent install what a task needs: the sandbox is the boundary. Add your
# own packages to the list.
RUN apt-get update \
  && apt-get install -y --no-install-recommends ca-certificates curl git sudo \
  && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
    -o /usr/share/keyrings/githubcli-archive-keyring.gpg \
  && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
    > /etc/apt/sources.list.d/github-cli.list \
  && apt-get update \
  && apt-get install -y --no-install-recommends gh \
  && rm -rf /var/lib/apt/lists/*

# fctl, for every user: a static build, which runs on any Linux. An empty
# FCTL_VERSION installs the latest release. The host puts its own fctl-agent
# into the sandbox each time a session starts, so the archive's goes.
ARG FCTL_VERSION=
RUN curl -fsSL https://fctl.sh/install \
    | env FCTL_VERSION="$FCTL_VERSION" FCTL_INSTALL_DIR=/usr/local/bin FCTL_NO_COMPLETIONS=1 sh \
  && rm -f /usr/local/bin/fctl-agent-*-linux

# The user sessions run as, with sudo and the package caches' directory.
# Ubuntu's images come with the user ubuntu at uid 1000: agent takes its
# place.
RUN if id ubuntu >/dev/null 2>&1; then userdel --remove ubuntu; fi \
  && useradd --create-home --shell /bin/bash --uid 1000 agent \
  && echo 'agent ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/agent \
  && chmod 0440 /etc/sudoers.d/agent \
  && install -d -o agent -g agent /var/cache/fctl

# Claude Code, the native build, in ~/.local/bin, as the user. Claude and its
# commands find their tools through the image's PATH, and so do setup
# scripts: Ubuntu's login shells keep it.
USER agent
WORKDIR /home/agent
RUN curl -fsSL https://claude.ai/install.sh | bash
ENV PATH=/home/agent/.local/bin:$PATH

The sandbox repository's examples/check.sh checks an image for what fctl needs: it runs in the image as its user, in place of the image's ENTRYPOINT as in a session, and says what's missing.

curl -fsSL https://raw.githubusercontent.com/hyperstructure/sandbox/main/examples/check.sh -o check.sh
docker run --rm -i --entrypoint sh my-sandbox -s < check.sh

Then build the image for both architectures, push it and choose it for the project, as Your own image describes.

Building it from the repository

A project can build its image from a Dockerfile or a dev container configuration in its repository instead, so that the environment lives next to the code and changes with it. In Settings → Sandbox → Image, pick "Built from the repository" and name the file, or from the CLI:

fctl projects set -p my-app --build Dockerfile
fctl projects set -p my-app --build docker/agent.Dockerfile --build-context app
fctl projects set -p my-app --build .devcontainer/devcontainer.json
fctl projects set -p my-app --build ""     # stop building

The project needs a repository, and its build replaces any image it chose. Only hosts whose owners allow builds from the repository take its sessions (allowed_builds, below), and only those with the Apple container, Docker or Firecracker driver.

When a session starts in a new sandbox, the host:

  1. Reads the file at the tip of the project's default branch, with the session's GitHub token, and works out what the build reads: the Dockerfile, and the directory it builds in (the repository's root unless the setting or the dev container configuration names another).
  2. Uses its last build when none of that changed since. Changes outside the directory don't count, but with the repository's root as the directory, every change does. In a busy repository, give the image a directory of its own (--build-context docker, say, or the .devcontainer directory a dev container configuration builds in by default); the builder's cache keeps the builds that follow short anyway.
  3. Otherwise downloads the repository at that commit (up to 2 GiB), keeps only the directory, and builds the image with docker build, container build or, with Firecracker, BuildKit in a VM of the project's own (whose image, docker.io/moby/buildkit, the host pulls from Docker Hub for the first), from the Dockerfile's text as GitHub sent it. The session's log shows each step. Sessions that need the same build wait for the one that builds it. Builds pass no secrets: a Dockerfile that needs a token should leave that step to the setup script.
  4. Tags the image fctl-build-<project id>:<hash>, and removes the project's earlier build, unless the runtime keeps it for a sandbox made from it (Docker does).

When GitHub can't be reached, sessions start from the last build of the same setting and say so; any other problem, like a file that isn't there, fails the session with the reason. A dev container configuration's image, with no build, is used as it is, from its registry.

Limits. A host builds one image at a time, and reads no Dockerfile or configuration larger than 1 MiB. A build that takes longer than build_timeout_minutes (60) is stopped, and an image larger than max_build_mb (20 GiB) is removed, where the runtime reports image sizes (Docker and Firecracker do); the session fails and says why. A build runs in the runtime's builder, not in a sandbox, so the project's CPU and memory settings don't apply: with Docker it gets what the Docker daemon has (on macOS, its VM), with Apple container what its builder VM has (container builder start --cpus 8 --memory 16g sizes it), and with Firecracker the host's default sandbox size (cpus and memory_mb in host.toml).

What fctl reads from a dev container configuration. image, or build.dockerfile, build.context, build.args and build.target (dockerFile and context at the top level in older ones), with paths relative to the configuration's directory. It leaves out features, lifecycle commands like postCreateCommand, containerEnv, mounts and runArgs, and says so in the session's log: put what they install into the Dockerfile, and what they run into the project's setup script. Sessions run as the image's user rather than remoteUser, so end the Dockerfile with USER vscode, say, to run as that user. Docker Compose configurations aren't built.

The image still needs what every image needs (below): most dev container images lack Claude Code and fctl. Start the Dockerfile FROM ghcr.io/hyperstructure/sandbox:0.14, or install them in it as An image from another base does: fctl for every user, and Claude Code as the user sessions run as.

Which images a host runs

A project's image and its build run on machines that belong to other people, with the session starter's Claude token and the session's GitHub tokens inside them (Security). So each host's owner decides, in its host.toml:

# Images projects may choose; the host's own `image` always runs. Unset: any.
allowed_images = [
  "ghcr.io/hyperstructure/sandbox",                     # any tag of it
  "ghcr.io/acme/*",                                     # anything under ghcr.io/acme/
  "ghcr.io/partner/agent@sha256:4f1c…",                 # this build only
]
# Repositories whose Dockerfile or devcontainer.json it builds. Unset: none.
allowed_builds = ["acme/*", "partner/app"]
build_timeout_minutes = 60
max_build_mb = 20480

The same lists from the CLI, each flag repeated for more entries (--allow-image '*' allows any image, --allow-build "" none):

fctl host install --allow-image 'ghcr.io/acme/*' --allow-image ghcr.io/hyperstructure/sandbox \
  --allow-build 'acme/*'

The host sends the lists to the control plane when it connects, so run fctl host restart after editing host.toml. The control plane gives a session only to a runner that runs its project's image or builds it, and the runner checks again. A session that no runner online allows stays queued and says why: "No runner allows this project's image, ghcr.io/acme/agent:1", or "No runner builds this project's image from acme/app". Admin → Runners, fctl admin runners and fctl host status show each runner's image and lists.

What an image needs

An image that doesn't start from the default one needs what follows (An image from another base builds one on Ubuntu, and the sandbox repository's examples/check.sh checks an image for it). It needs no fctl-agent: the host copies its own in (What fctl writes into a sandbox).

What fctl writes into a sandbox

At session start, fctl copies fctl-agent into /opt/fctl/bin, which it gives to root, and starts it as root (docker exec -u 0, sudo in Lima, root in a Firecracker VM). It keeps root as its real user, so that the image's user, whom Claude and its commands run as, can't signal it: a kill or pkill that matches it by accident fails with "Operation not permitted". Otherwise it works as that user, so what it writes in the user's home is the user's. Where the sandbox gives root the capability (CAP_SYS_RESOURCE: Lima's and Firecracker's VMs do, Docker's containers don't), it keeps itself from the OOM killer, so that a build that fills the sandbox's memory takes the build rather than fctl-agent. Root can still stop it, and agent has sudo: this guards against accidents, not against an agent set on it. A host whose owner turns this off (agent_as_root = false in host.toml) runs nothing as root in Docker, Apple container and Lima sandboxes: the image's user puts fctl-agent in its own ~/.fctl/bin and runs it, with its files in ~/.fctl, where the agent's commands can stop it. A sandbox where it already ran as root keeps it so. It writes:

Claude's environment has the project's variables and secrets, CLAUDE_CODE_OAUTH_TOKEN and its scopes, IS_SANDBOX=1, DISABLE_AUTOUPDATER=1, GIT_TERMINAL_PROMPT=0, FCTL_SESSION_ID, FCTL_SESSION_URL, FCTL_SESSION_SOCKET, the sandbox's size in FCTL_SANDBOX_CPUS and FCTL_SANDBOX_MEMORY_MB, and in projects that keep a memory CLAUDE_CODE_DISABLE_AUTO_MEMORY=1. ANTHROPIC_* variables and the Bedrock, Vertex and Foundry switches never reach it. The setup script has the image's environment, the project's variables and secrets, the clouds' variables, the sandbox's size and, on hosts after fctl 0.38.1, FCTL_SESSION_ID, FCTL_SESSION_URL and FCTL_SESSION_SOCKET, so that fctl id-token works there as it does for the agent.