Skip to content
docs
type to search↑↓ move↵ openesc close
v0.2.4github

Templates

4 min readv0.2.4this page as markdown

A template is a sandbox prepared once and saved as a snapshot, so every sandbox made from it starts in the same state. Installs and builds run once, when the template is made, never again per sandbox.

Part What it holds
Source An image on container, gvisor or vm, or no image on process or wasm
Build Files copied in, commands run, and an optional readiness check
Snapshot The prepared data directory, saved as an immutable version
Start command What runs in each new sandbox, in its data directory unless workdir says otherwise
Tier The tier the snapshot was made on; every sandbox from it runs there too

Start from a template

Pass the template’s name or ID when you create a sandbox. Hermitbox forks the newest version’s snapshot and runs its start command.

typescript
// Each sandbox from it starts with the dependencies installed.
const box = await hb.sandbox({ template: 'my-api' })
python
# Each sandbox from it starts with the dependencies installed.
box = hb.sandbox(template='my-api')

A create takes exactly one source: an image, a snapshot or a template. A sandbox from a template is an ordinary fork: it has its own ID and data, and changes never reach the template.

Build one from code

hb.template starts a sandbox from from, copies your files in, runs each run command, and snapshots the result. The copy happens from your machine; only the build plan and the finished snapshot reach control.

typescript
// Copy the project in, install its dependencies, and save the result.
const template = await hb.template({
  name: 'my-api',
  from: 'node:22',
  copy: [['./', 'app']],
  run: ['cd /data/app && npm ci'],
  start: 'cd app && npm start',
})
python
# Copy the project in, install its dependencies, and save the result.
template = hb.template(
    name='my-api',
    from_='node:22',
    copy=[('./', 'app')],
    run=['cd /data/app && npm ci'],
    start='cd app && npm start',
)

Each run and ready command has up to ten minutes. A failed step says how it ended (its exit code, a signal or a timeout), and the build deletes its sandbox. The CLI runs the same builder from a file: hermitbox template build -f hermitbox.template.ts.

Template versions

Each build registers a new, numbered version, and a version never changes. template.rebuild() builds the next one from the same local files. New sandboxes start from the newest version, and hb.templates() lists them.

A snapshot that a version uses can’t be deleted, and neither can the sandbox that built it, while that version exists.

Templates from a spec

POST /v1/templates takes a name and a spec: the same fields as a create, such as image, isolation, entrypoint and env, with no snapshot or template as its source. Control prepares it once on each active node that serves the spec’s tier and keeps a stopped snapshot there. A sandbox from it forks a ready copy in its region.

Bucket mounts carry credentials, so a template never stores them. Pass them when you create each sandbox.

Built-in templates

hermitbox template create builds the plans Hermitbox ships for python-interpreter, node-interpreter, desktop, browser and tools. Starter projects such as nextjs, vite-react and fastapi are prepared on a container-capable node the first time a sandbox asks for one. hermitbox template from <repo> prepares a Git repository the same way.

Next steps

run it yourself
$curl -fsSL https://hbx.sh | sh
or ask your agent
Install Hermitbox and set it up for me
Linux (x86_64 or aarch64), no root, no Docker. Agents can read every page: llms.txt · llms-full.txt
the floor · nothing below this line