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.
| Parameter | Type | Default | Description |
|---|---|---|---|
params | CreateSnapshotParams | — | See fields below. |
options.onLogs | (chunk: string) => void | — | Receives progress messages and build-log lines. |
options.timeout | number | 0 | Seconds to wait for a terminal state; 0 waits indefinitely. |
CreateSnapshotParams fields:
| Field | Type | Default | Description |
|---|---|---|---|
name | string | — | Snapshot name (used later in daytona.create({ snapshot: name })). |
image | string | — | Registry ref to alias/cache, e.g. python:3.12-slim. Mutually exclusive with dockerfile. |
dockerfile | string | — | Inline Dockerfile to build. Must be self-contained — no COPY/ADD of local files. Mutually exclusive with image. |
resources | Resources | — | Default cpu/memory/disk for sandboxes created from this snapshot. |
entrypoint | string[] | — | 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.
See image sources for Dockerfile-build details.
get()
Fetches a snapshot by name or id.
Returns: the Snapshot DTO, including state (pending, building, active, error, or build_failed). Throws: DaytonaNotFoundError if it does not exist.
list()
Lists snapshots, paginated.
| Parameter | Type | Default | Description |
|---|---|---|---|
page | number | — | Page number (1-based). |
limit | number | — | Items per page. |
Returns: { items: Snapshot[], total, page, totalPages }.
activate()
Activates a snapshot. This is a no-op once the snapshot's image is cached and ready; it exists for Daytona API compatibility.
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.