Skip to content

Daytona.Snapshot reference

Source: packages/daytona/src/CreateSnapshot.ts

Build Daytona snapshots at runtime: a warm base per repository, built when it’s first needed, that later sandboxes start from. To capture a sandbox you already have, use sandbox.createSandboxSnapshot on its handle.

The host gets its own Daytona API key with write:snapshots, delete:snapshots and, for from builds, write:sandboxes and delete:sandboxes. Snapshots have only a name, so the prefix you give is how you find the ones it created. They are not deleted when the stack is destroyed: list() and delete the names with your prefix to clean them up.

CreateSnapshot: A Warm Base per Repository

Section titled “CreateSnapshot: A Warm Base per Repository”
const images = yield* Daytona.CreateSnapshot({ prefix: "repo-" });
const name = `repo-${owner}-${repo}`;
const base =
(yield* images.get(name)) ??
(yield* images.create({
name,
from: "daytonaio/sandbox:0.4.3",
run: [`git clone https://github.com/${owner}/${repo} /home/daytona/repo`, "cd /home/daytona/repo && npm ci"],
}));
const sandbox = yield* sandboxes.create({ snapshot: base.name });

Source: packages/daytona/src/Snapshot.ts

A Daytona snapshot: the image sandboxes boot from, with its default size. Pull one from a registry, build one from a Dockerfile on Daytona’s builders, or capture one from a sandbox after running setup commands in it (a warm base to fork from).

Snapshots are immutable: changing what one is built from replaces it. Daytona deactivates a snapshot after two weeks without use; deploy reactivates it.

export const Node = Daytona.Snapshot("Node", {
image: "node:22-bookworm",
cpu: 2,
memory: 4,
disk: 10,
});
export const Base = Daytona.Snapshot("Base", {
dockerfile: Dockerfile.inline`
FROM node:22-bookworm
RUN apt-get update && apt-get install -y git ripgrep
`,
cpu: 2,
memory: 4,
});
export const App = Daytona.Snapshot("App", {
context: "./sandbox",
build: { args: { NODE_ENV: "production" } },
});
export const App = Daytona.Snapshot("App", {
context: "./sandbox",
build: {
remote: false,
secrets: { npmrc: Redacted.make(process.env.NPM_TOKEN!) },
},
});
export const Warm = Daytona.Snapshot("Warm", {
from: Base,
run: [
"git clone https://github.com/alchemy-run/alchemy /home/daytona/alchemy",
"cd /home/daytona/alchemy && pnpm install",
],
});

Snapshot.lookup references a snapshot Alchemy doesn’t manage (created in the Daytona dashboard or by another stack). It is read during plan/deploy, never created, updated or deleted. buildHash is empty: the image wasn’t built by this stack.

const base = Daytona.Snapshot.lookup({ name: "python-ml" });