Skip to content

minisandbox.yaml

A template is built from a minisandbox.yaml recipe. This page lists every field ons and the API accept. For a walkthrough, read Templates.

minisandbox.yaml
version: 1
name: web-app
from: dev-base
resources:
vcpu: 2
memory: 4GiB
disk: 16GiB
workdir: /home/user/app
files:
- src: .
dest: /home/user/app
ignore: [node_modules, .git, "*.log"]
env:
NODE_ENV: development
setup:
- curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
- sudo apt-get install -y nodejs
- npm ci
start:
cmd: npm run dev
ready:
http: http://localhost:3000/
timeout: 2m
on_start:
- git pull --ff-only || true
egress:
presets: [ubuntu, npm, github]
allow:
- deb.nodesource.com
ports: [3000]
  • The file is at most 256 KiB, nested at most 32 levels.
  • YAML anchors, aliases and tags are refused. Write values out in full.
  • Duplicate keys and unknown fields are refused.
  • ons reports every problem in one pass, each with its file, line and column, and the fix:
minisandbox.yaml:12:3: unknown field `setpu` · did you mean `setup`?
minisandbox.yaml:4:1: `from`, `image` and `dockerfile` are exclusive · keep one

Sizes take a binary unit: KiB, MiB, GiB or TiB (512MiB, 8GiB). Durations take s, m or h (90s, 10m, 2h).

Required. Always 1.

Required. The template’s name in your organization: lowercase letters, digits and dashes, starting with a letter or a digit, 63 characters at most. You start miniVMs from it with ons create --template <name>.

Exactly one is required. It sets what the template starts from.

Field Value
from A template of your organization, or a base template: dev-base, dev-agents.
image An OCI image reference from a public registry, such as ghcr.io/<org>/<image>:<tag> or <name>@sha256:<digest>. A tag is resolved to a digest at build time.
dockerfile A path to a Dockerfile, relative to the recipe and inside its directory. That directory is the build context.

With from, the template inherits the base’s disk and its resolved env. It does not inherit the base’s resources, egress, ports or start: write the ones you need in your recipe.

With dockerfile:

  • A .dockerignore next to the Dockerfile trims the context (same syntax as ignore below; ! exceptions are refused).
  • A # syntax= line (a custom BuildKit frontend) is refused.
  • ons warns when the context holds .git or a .env* file, which a COPY . . would freeze into every snapshot.

devcontainer is refused for now: use dockerfile.

The size of every miniVM of the template. A field you leave out takes the default below, never the base template’s.

Field Default Rule
vcpu 2 1 or an even number up to 32.
memory 2GiB At least 128MiB.
disk 8GiB Must hold the image plus 512MiB.

Your organization’s limits cap what a create may ask for. On the managed service, a miniVM has at most 8 vCPU and 16 GiB of memory today. See Quotas and limits.

The user that runs setup, start and on_start, and the commands and file calls of an SDK that names no user. Default user. When the image already has this account, the build uses it as is. When it does not, the build creates it with uid 1000, home /home/<user> and passwordless sudo. If uid or gid 1000 is already taken in the image (ubuntu:24.04 has ubuntu), the build fails and says what to set instead: an account of the image, or root. With user: root, no other account is created. Lowercase letters, digits, _ and -, 32 characters at most.

An absolute path, created if missing and owned by user. Default /home/<user>, or /root for root.

Files copied from your machine into the template at build time. A list of:

Field Rule
src Relative to the recipe’s directory and inside it. . is the directory itself.
dest An absolute path in the template.
ignore Optional. Names skipped at any depth (node_modules, *.log) or paths from src (dist/cache). * and ? match inside one name. At most 1000 patterns.

Symlinks are copied as links and never followed. What lands under the user’s home or workdir belongs to user; anything else belongs to root. The packed context is at most 2 GiB and 100 000 entries.

Environment variables for setup, start, on_start and every miniVM of the template.

env:
NODE_ENV: production
LOG_LEVEL: info
  • Names use uppercase letters, digits and _, and do not start with a digit.
  • The prefixes MSB_ and E2B_ are reserved.
  • A value is at most 32 KiB. All variables together, with the base’s: at most 1024 variables and 128 KiB.
  • With from, your names override the base’s one by one, without interpolation: a PATH here replaces the base’s PATH whole.

Shell lines run once, at build, in order. Each runs through bash -lc as user, in workdir, with env and the template’s egress. A non-zero exit fails the build. An empty line is refused.

Optional. A long-running process started after setup and kept alive in the snapshot, so each miniVM starts with it already running.

start:
cmd: npm start
ready:
http: http://localhost:3000/health
timeout: 90s
Field Rule
cmd The command. It must stay in the foreground: npm start & fails the build.
ready Required. Exactly one of http, tcp or cmd, plus an optional timeout.
ready.http A plain http://localhost… URL (or 127.0.0.1, [::1]) that answers 2xx.
ready.tcp A port that accepts connections.
ready.cmd A command that exits 0 once the process is ready.
ready.timeout Default 60s, at most 10m.

Shell lines run in the background after each start of a miniVM from the template, as user in workdir. A create does not wait for them.

Outbound network access. Closed when absent. It applies to setup, start and every miniVM of the template.

egress:
presets: [github, npm]
allow:
- api.example.com
- "*.example.org"
Field Rule
presets Named lists of domains, below.
allow Lowercase domains of two labels or more, optionally starting with *.. IP addresses are refused.

At most 256 domains in total, presets expanded.

Preset Domains
github github.com, api.github.com, codeload.github.com, uploads.github.com, raw.githubusercontent.com, objects.githubusercontent.com, release-assets.githubusercontent.com, github-cloud.githubusercontent.com
npm registry.npmjs.org, registry.yarnpkg.com, repo.yarnpkg.com, nodejs.org
pypi pypi.org, files.pythonhosted.org
crates crates.io, index.crates.io, static.crates.io, static.rust-lang.org
ubuntu archive.ubuntu.com, *.archive.ubuntu.com, security.ubuntu.com, ports.ubuntu.com, snapshot.ubuntu.com
docker-hub registry-1.docker.io, auth.docker.io, index.docker.io, production.cloudflare.docker.com, production.cloudfront.docker.com
ghcr ghcr.io, pkg-containers.githubusercontent.com
llm-apis api.anthropic.com, api.openai.com, platform.claude.com, claude.ai, generativelanguage.googleapis.com, api.mistral.ai, openrouter.ai, opencode.ai, models.dev

A create can narrow or widen this list for one miniVM, and you can change it while the miniVM runs. More in Egress.

Ports of the miniVM you can open as preview URLs. Port 0 and 49983 (reserved for the miniVM’s agent) are refused, and a port may be listed once. See Processes, files and ports.

lifecycle:
timeout: 2h
idle:
after: 15m
action: pause
Field Rule
timeout A positive duration.
idle.after A positive duration.
idle.action pause or kill.
placement:
pool: <pool-name>

<pool-name> is a pool of your organization (lowercase letters, digits and dashes). miniVMs of the template are placed there. You only need it with miniVMs on your own servers.

A recipe never holds a secret value. The secrets field is refused for now (secrets are not supported yet). Pass secret values when you create a miniVM instead:

  • as environment variables of the create, with the E2B SDK (envs of Sandbox.create);
  • as egress credentials, which the platform adds to the miniVM’s outbound requests without the miniVM ever seeing them. See Egress.

setup and start run without any secret, so no snapshot holds one.

Terminal window
ons template validate
ons template build --dry-run

Both run offline. --dry-run also prints the digests the build would use. Pass --file <path> for a recipe that is not ./minisandbox.yaml.