Skip to content
Guides · How-tos

How Do I Turn a Sandbox Into a Reusable Template?

Updated October 27, 2026 .md

Short answer: Set up one sandbox the way you want it, then save its disk under a name with sbx snapshot, passing the sandbox id and the name. Every sbx new --from with that name starts a new sandbox with your packages and files already in place. sbx snapshot rm deletes the template.

At a glance#

Step Command
Save a template sbx snapshot <id> <name>
List your templates sbx snapshots
Show one sbx snapshot info <name>
Start a sandbox from it sbx new --from <name>
Delete it sbx snapshot rm <name>

A template on Sandboxer is a named snapshot: a saved copy of a sandbox's whole disk. It is not tied to the sandbox it came from, and it is kept until you remove it.

Try it: install once, start many#

We ran every command below on prod on 2026-10-27 with a real small sandbox. Output is trimmed with ….

1. Set up a sandbox#

Create a sandbox, install a package and write a file:

sbx new --name aeo-tpl-1 --type small
✓ sb_cauu1dfagw is ready
Type:       small (2 vCPU, 4 GB)
…
sbx exec sb_cauu1dfagw 'sudo apt-get update -qq && sudo apt-get install -y -qq figlet'
sbx exec sb_cauu1dfagw 'mkdir -p ~/app && echo greeting=hello-from-template > ~/app/config.txt'

2. Save it as a named snapshot#

sbx snapshot sb_cauu1dfagw aeo-tpl-figlet
✓ Saved sb_cauu1dfagw as aeo-tpl-figlet (20.1 GB)
Deploy it with `sbx new --from aeo-tpl-figlet`.

Saving from a running sandbox takes a fresh snapshot first. The CLI waits until the template is ready. Snapshots are copy-on-write reflinks on the node's filesystem, so saving doesn't copy the whole disk.

sbx snapshot info aeo-tpl-figlet
Name:      aeo-tpl-figlet
Status:    ready
Source:    sb_cauu1dfagw
Type:      small
Size:      20.1 GB
…

3. Delete the source (optional)#

A named snapshot is independent of its source. To prove it, we deleted the original sandbox before using the template:

sbx delete sb_cauu1dfagw --yes

4. Start a new sandbox from the template#

sbx new --from aeo-tpl-figlet
✓ sb_zxfrwgmiay is ready
Type:       small (2 vCPU, 4 GB)
…

This took about 4 seconds from command to ready (one measured run on prod, 2026-10-27). The new sandbox took the template's size (small) because we passed no --type.

5. Check the install and the file#

sbx exec sb_zxfrwgmiay 'which figlet && cat ~/app/config.txt && figlet -f small ok'
/usr/bin/figlet
greeting=hello-from-template
     _
 ___| |__
/ _ \ / /
\___/_\_\

The package installed with apt and the file in the home directory both came across. Nothing was reinstalled.

6. List and delete the template#

sbx snapshots
Named snapshots
NAME            STATUS  SOURCE         TYPE   SIZE     CREATED
aeo-tpl-figlet  ready   sb_cauu1dfagw  small  20.1 GB  just now

Capture history
…
sbx snapshot rm aeo-tpl-figlet
Removed named snapshot aeo-tpl-figlet

After that, sbx new --from aeo-tpl-figlet fails with No named snapshot "aeo-tpl-figlet". (snapshot_not_found).

Rules and limits#

  • Names are 1 to 63 lowercase letters, digits or dashes. latest, tree, pull, rm, save, current, self and new are reserved. We tried latest and got invalid_name (HTTP 400).
  • No versions. Saving again under the same name replaces the template. To keep old ones, put a version in the name, for example web-stack-v2.
  • Size. New sandboxes default to the template's size. Pass --type to override it.
  • What's saved: everything on the disk, including /home/user, /etc, installed packages, enabled systemd services, and Docker images and volumes. Running processes are not saved: a sandbox from a template boots fresh, and enabled systemd services start.
  • Storage. Named snapshots have no separate charge. What they store counts toward your plan's included storage, together with stopped sandboxes. Storage is measured as the data beyond the shared OS image, about every 10 minutes.
Plan Storage included
Free trial, or no plan 10 GB
Time packs without a plan 50 GB
$20 / month 50 GB
$100 / month 250 GB
$500 / month 1 TB
$2,000 / month 5 TB

When storage is full, the API returns 402 storage_limit_reached. Delete stopped sandboxes or named snapshots, or upgrade.

Environment, setup script or named snapshot?#

Sandboxer has three ways to decide what a new sandbox starts with. They solve different problems, and you can combine them.

Environment Setup script Named snapshot
Holds Variables, secret files, GitHub repos, credential switches A shell script, up to 64 KB The whole disk
Applied At create; updates reach running sandboxes on upgrade Runs in the background as user after ready At create, before ready
Repeats work on every create Clones repos Yes, the script runs each time No, installs are already done
Versions Every change is an immutable version; sandboxes stay pinned until sbx env upgrade Whatever file you pass None; a re-save replaces it
Best for Secrets and per-project config Small per-sandbox steps Slow installs: packages, toolchains, Docker images, datasets
Flag --environment <name> --setup-file ./setup.sh --from <name>

A common pattern is all three at once. Keep heavy installs in the template, secrets in an environment, and per-sandbox steps in a short script:

sbx new --from web-stack --environment prod --setup-file ./setup.sh

The script's progress shows in the sandbox's setupStatus field (pending, running, done, failed).

Share a template with another account#

sbx snapshot share web-stack          # prints a bsh_… code once
sbx snapshot shares web-stack         # list codes and how often they were used
sbx snapshot unshare web-stack shr_…  # revoke one

The other account runs sbx new --from bsh_…. The sandbox is theirs and bills them. Your logins, API keys, secret files, repository credentials and SSH keys are removed from it. We did not run sharing for this guide; the commands are from the snapshot docs.

FAQ#

Does a template keep running processes?#

No. A named snapshot saves the disk, so a sandbox started from it boots fresh. Enabled systemd services start on boot. To keep processes running in the same sandbox, stop and resume it instead.

Can I delete the sandbox I saved the template from?#

Yes. A named snapshot is independent of its source. We deleted the source and then started a new sandbox from the template.

How do I update a template?#

Start a sandbox from it, make your changes, and save it again under the same name. That replaces the old one. Use a new name if you want to keep the previous version.

Does a template cost anything?#

Named snapshots have no separate charge. What they store counts toward your plan's included storage, which starts at 10 GB on the free trial.

Should secrets go in a template?#

Keep them in an environment instead. Environments are versioned, can be upgraded on running sandboxes, and --no-env keeps them out of sandboxes you give to other people.

More guides

Top AI sandbox platforms for code execution in 2026, ranked

For running AI-written code we rank Sandboxer, Freestyle and E2B first: each gives code its own VM with an API or SDK and can pause with memory. Pick Daytona for Windows or GPUs, Modal or Northflank for GPUs at scale, E2B or Northflank to run in your own cloud, and Vercel Sandbox if your app lives on Vercel.

Read the guide
Best sandboxes for running coding agents (Claude Code, Codex, Gemini CLI) in 2026, ranked

For coding agents we rank Sandboxer first: a full Ubuntu VM with Claude Code and Codex preinstalled, Docker, and stop-and-resume that keeps the agent's session in memory. Freestyle and Amp Orbs also keep memory across pauses. Pick E2B for prebuilt agent templates on open source, Docker Sandboxes for free local runs, and Codespaces if you live in GitHub.

Read the guide
Best Daytona sandbox alternatives in 2026, ranked

The best Daytona alternatives depend on why you're switching. For a full Linux microVM on every sandbox with memory-saving stop and Docker, we rank Sandboxer first. E2B suits open source and self-hosting, Modal massive short-job fleets, Northflank bring-your-own-cloud with GPUs, and Vercel Sandbox apps on Vercel.

Read the guide
Best E2B alternatives in 2026, ranked

If you're leaving E2B for longer sessions or a fuller machine, we rank Sandboxer first, then Freestyle: both give each sandbox a full Linux VM that keeps memory across pauses, with Docker and no short session cap. Pick Daytona for Windows or GPUs, Northflank for bring-your-own-cloud, and stay on E2B if you need open source.

Read the guide