---
title: "Custom sandbox templates from a running sandbox · Pethost"
description: "Save a Pethost sandbox’s disk, packages and Docker images included, as a template, and start new sandboxes from it in about 0.22 s. Free within your plan."
---

[Agent Sandboxes](https://pethost.dev/sandboxes/) Save a sandbox as a template

# Templates: install once, start every sandbox from it

Install what your work needs once, in a sandbox, by hand or by an agent. Save the sandbox’s disk as a template, and every new sandbox starts with all of it in place: packages, files, Docker images.

A sandbox with its packages and Docker images is saved as the template my-app@3 in 1.2 s, and three new sandboxes start from it on two servers.

## Ours: base

Every sandbox starts from a template. Ours is `base`: Ubuntu 24.04 with build-essential, git, curl, wget, ripgrep and jq; Python 3 with pip and venv; Node.js 22; Claude Code, Codex and OpenCode with their SDKs; Docker with Compose and Buildx; and a 1280×800 desktop with Google Chrome. You work as `user`, with sudo and no password. Its root filesystem is read-only and read straight from the server’s disk, so what a sandbox does not run costs it no memory, and neither the desktop nor Docker starts until something asks for it.

Each version of `base` is named by the sha256 of what it holds: the operating system, its packages and the guest kernel. We build a new one every month, and at once for a security fix of Chrome, the kernel or the packages. New sandboxes start on the newest; a sandbox, and a template saved from it, keep the base the sandbox started on.

## Custom templates, saved from a sandbox

A custom template is a sandbox’s disk saved over our base. Set the sandbox up, by hand or by an agent, then `create_template` saves its disk as the next version of a name: `my-app@1`, then `my-app@2`. It saves files only: no memory, no running processes, and none of the sandbox’s command history or agent conversations, which new sandboxes start without.

The call answers in 28 to 49 ms with the version SAVING. A running sandbox goes on running, halted for some milliseconds while its disk is taken. Then the server checks the filesystem and shrinks it to what it holds, in a helper VM of its own, and uploads only the chunks that are yours to object storage, compressed and encrypted with a key for that version alone. A small sandbox’s version is READY 0.9 to 1.5 s after the call; in general it takes about 5 s, plus 10 s for each GiB of your own data. A READY version names its `min_size`, the smallest size whose disk holds what it saved.

## Starting sandboxes from it

Name the template when you create a sandbox: `my-app` takes its newest READY version, `my-app@3` exactly that one. Any server starts sandboxes from any version. The panel asks the servers that already hold the version first, and there a create takes 218 to 225 ms. A server that lacks it fetches it once, about 10 s for each GiB the version holds, and keeps it for the next. A sandbox from a template takes any size from the version’s `min_size` up.

Docker’s images live on the sandbox’s disk, so a template carries them: a sandbox made from it runs `docker run` on an image it never pulled. (Times here were measured through a panel 16 ms from the server.)

Python

CLI

```
import time

from pethost.sandboxes import Sandboxes

sandboxes = Sandboxes()  # reads PETHOST_TOKEN
sandbox = sandboxes.create_sandbox()  # from base
sandboxes.run_command(
    sandbox.sandbox_id,
    command="python3 -m venv ~/venv && ~/venv/bin/pip install pandas && docker pull postgres:18",
)

version = sandboxes.create_template("my-app", sandbox_id=sandbox.sandbox_id)
name = f"my-app@{version.version}"
while sandboxes.get_template(name).state.name == "SAVING":
    time.sleep(1)

copy = sandboxes.create_sandbox(name)  # pandas and the postgres image are there
print(sandboxes.run_command(copy.sandbox_id, command="docker images postgres").stdout)
```

```
pethost sandbox template save api-dev my-app   # its disk, as the next version of my-app
pethost sandbox template show my-app           # SAVING, then READY
pethost sandbox new --template my-app          # a new sandbox from the newest version
```

## Versions, room and price

A name holds up to 10 versions. A workspace saves one version at a time, and its versions together fit in its plan’s template room, counted as what they take in object storage, compressed:

| Plan | Template room |
| --- | --- |
| $20 a month | 5 GiB |
| $100 a month | 30 GiB |
| $500 a month | 175 GiB |
| $2,000 a month | 800 GiB |

Templates cost nothing beyond that room. Deleting a template, every version of its name, frees its room at once, and the sandboxes made from it go on running, pausing, stopping and resuming: object storage keeps a version until the last of them is deleted.

## What templates do not do yet

There is no build from a Dockerfile yet: install in a sandbox and save it, as above. A template carries files, never running processes. To copy a sandbox with its memory and processes, a dev server running or an agent halfway through a task, [fork it](https://pethost.dev/sandboxes/fork/). Each sandbox, from a template or not, is its own [Firecracker microVM](https://pethost.dev/sandboxes/firecracker-microvm/) with its own kernel. The [templates guide](https://pethost.dev/docs/sandboxes/templates/) has every call and field.

## How it compares

On 21 November 2026, E2B built templates with its template builder, and Daytona made snapshots from an image or a Dockerfile, which Pethost does not do yet. boat.dev saves snapshots and charges $0.056 a snapshot a day past those its plan includes. A Pethost template costs nothing within your plan’s room.

[Read the docs](https://pethost.dev/docs/sandboxes/templates/)

## Questions

**Can I build a sandbox template from a Dockerfile?**

Not yet. Start a sandbox from `base`, run your Dockerfile’s steps in it as commands, and save it. You can also run `docker build` inside a sandbox: the image it builds is on the sandbox’s disk, and the template carries it.

**What does a template cost?**

Nothing. Its versions count against your plan’s template room, 5 GiB on the $20 plan, measured as they are stored, compressed.

**Does a template keep running processes?**

No, it keeps files. A fork copies a sandbox with its memory and running processes.

**How fast does a sandbox start from a template?**

In 218 to 225 ms on a server that holds the version. The first start on a server that does not fetches it first, about 10 s for each GiB it holds.

## Related

- [One running sandbox at step 41 of a task is forked into three copies in 0.25 s; each carries on from step 41 on its own. Fork, memory and all Copy a running sandbox, its memory, processes and disk, into new sandboxes in one call. Three copies take about a quarter of a second. How it works](https://pethost.dev/sandboxes/fork/)
- [Three sandboxes on one server, each a microVM with its own kernel and its own root shell; a fourth starts in 0.12 s. A microVM per sandbox Each sandbox is a Firecracker microVM with its own Linux kernel, root inside and its own network, started from a snapshot in about 0.15 s. How it works](https://pethost.dev/sandboxes/firecracker-microvm/)

## Give your agent a computer in 0.15 s

[Start the free trial](https://console.pethost.dev/welcome?kind=sandboxes)

Pethost · Stephan Gomer · NIP 1133096755

Pethost

- [Templates](https://pethost.dev/templates/)
- [About](https://pethost.dev/about/)
- [Docs](https://pethost.dev/docs/)
- [Blog](https://pethost.dev/blog/)
- [API](https://pethost.dev/docs/api/)
- [CLI](https://pethost.dev/docs/cli/)
- [Plugin](https://github.com/pethost-dev/plugin)
- [Terms](https://pethost.dev/terms/)
- [Privacy](https://pethost.dev/privacy/)
- [Refunds](https://pethost.dev/refunds/)
- [support@pethost.dev](mailto:support@pethost.dev)

Databases

- [Postgres](https://pethost.dev/postgres/)
- [Valkey](https://pethost.dev/valkey/)

Agent Sandboxes

- [Sandboxes](https://pethost.dev/sandboxes/)
- [Pricing](https://pethost.dev/sandboxes/#pricing)
- [Docs](https://pethost.dev/docs/sandboxes/)
- [API](https://pethost.dev/docs/sandboxes/api/)

Comparisons

- [Coolify vs Dokploy vs CapRover vs Dokku](https://pethost.dev/blog/coolify-vs-dokploy-vs-caprover-vs-dokku/)
- [Coolify Cloud vs Dokploy Cloud](https://pethost.dev/blog/coolify-cloud-vs-dokploy-cloud/)
- [Railway vs Render vs Fly.io pricing](https://pethost.dev/blog/railway-vs-render-vs-fly-io-pricing/)
- [Managed Docker Compose hosting](https://pethost.dev/blog/managed-docker-compose-hosting/)

Alternatives

- [Railway alternatives](https://pethost.dev/blog/railway-alternatives/)
- [Heroku alternatives](https://pethost.dev/blog/heroku-alternatives/)
- [Dokploy alternatives](https://pethost.dev/blog/dokploy-alternatives/)
- [Coolify alternatives](https://pethost.dev/blog/coolify-alternatives/)
- [Render alternatives](https://pethost.dev/blog/render-alternatives/)
- [Sliplane alternatives](https://pethost.dev/blog/sliplane-alternatives/)
