DaytonaDocs

SnapshotService

Image-alias snapshots — pre-cached images and Dockerfile builds.

SnapshotService manages snapshots in the Daytona-dialect sense: named aliases for container images, cached ahead of sandbox creation so daytona.create({ snapshot: ... }) boots fast. Obtain it as daytona.snapshot.

Note: These are image aliases, not VM-state captures. To snapshot a running sandbox's disk or memory, use sandbox.createSnapshot(). See snapshot concepts.

create()

Creates a snapshot from either a registry image ref or an inline Dockerfile, then resolves once it reaches a terminal state (active on success). When options.onLogs is given, the service also streams the build logs line by line, in addition to state-change progress messages.

TypeScript
create(
  params: CreateSnapshotParams,
  options?: { onLogs?: (chunk: string) => void; timeout?: number },
): Promise<Snapshot>
ParameterTypeDefaultDescription
paramsCreateSnapshotParamsSee fields below.
options.onLogs(chunk: string) => voidReceives progress messages and build-log lines.
options.timeoutnumber0Seconds to wait for a terminal state; 0 waits indefinitely.

CreateSnapshotParams fields:

FieldTypeDefaultDescription
namestringSnapshot name (used later in daytona.create({ snapshot: name })).
imagestringRegistry ref to alias/cache, e.g. python:3.12-slim. Mutually exclusive with dockerfile.
dockerfilestringInline Dockerfile to build. Must be self-contained — no COPY/ADD of local files. Mutually exclusive with image.
resourcesResourcesDefault cpu/memory/disk for sandboxes created from this snapshot.
entrypointstring[]Entrypoint override.

Returns: the Snapshot DTO (id, name, state, resources, ...). Throws: DaytonaError if neither or both of image/dockerfile are given, if the build ends in error/build_failed, or if the timeout elapses.

TypeScript
const snap = await daytona.snapshot.create(
  { name: 'node-base', image: 'node:22-slim' },
  { onLogs: console.log },
)
const sandbox = await daytona.create({ snapshot: 'node-base' })

See image sources for Dockerfile-build details.

get()

Fetches a snapshot by name or id.

TypeScript
get(nameOrId: string): Promise<Snapshot>

Returns: the Snapshot DTO, including state (pending, building, active, error, or build_failed). Throws: DaytonaNotFoundError if it does not exist.

list()

Lists snapshots, paginated.

TypeScript
list(page?: number, limit?: number): Promise<PaginatedSnapshots>
ParameterTypeDefaultDescription
pagenumberPage number (1-based).
limitnumberItems per page.

Returns: { items: Snapshot[], total, page, totalPages }.

TypeScript
const { items } = await daytona.snapshot.list(1, 20)
for (const snap of items) console.log(snap.name, snap.state)

activate()

Activates a snapshot. This is a no-op once the snapshot's image is cached and ready; it exists for Daytona API compatibility.

TypeScript
activate(snapshot: Snapshot): Promise<Snapshot>

Returns: the updated Snapshot. The argument is a snapshot DTO (as returned by get/list); its id is used.

delete()

Deletes a snapshot. The argument is a snapshot DTO; its id is used.

TypeScript
delete(snapshot: Snapshot): Promise<void>
TypeScript
const snap = await daytona.snapshot.get('node-base')
await daytona.snapshot.delete(snap)

On this page