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.create_snapshot(). See snapshot concepts.
create()
Creates a snapshot from either a registry image ref or an inline Dockerfile, then blocks until it reaches a terminal state (active on success). State-change progress can be reported via on_logs.
| Parameter | Type | Default | Description |
|---|---|---|---|
params | CreateSnapshotParams | — | See fields below. |
on_logs | Callable[[str], None] | None | Called with progress messages as the snapshot changes state. |
timeout | int | 0 | Seconds to wait for a terminal state; 0 waits indefinitely. |
CreateSnapshotParams fields:
| Field | Type | Default | Description |
|---|---|---|---|
name | str | — | Snapshot name (used later in daytona.create(snapshot=name)). |
image | str | None | Registry ref to alias/cache, e.g. python:3.12-slim. Mutually exclusive with dockerfile. |
dockerfile | str | None | Inline Dockerfile to build. Must be self-contained — no COPY/ADD of local files. Mutually exclusive with image. |
resources | Resources | None | Default cpu/memory/disk for sandboxes created from this snapshot. |
entrypoint | List[str] | None | Entrypoint override. |
Returns: the snapshot dict (id, name, state, resources, ...). Raises: 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 dict, including state (pending, building, active, error, or build_failed). Raises: DaytonaNotFoundError if it does not exist.
list()
Lists snapshots, paginated.
| Parameter | Type | Default | Description |
|---|---|---|---|
page | int | None | Page number (1-based). |
limit | int | None | Items per page. |
Returns: {"items": [...], "total": int, "page": int, "total_pages": int}.
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 dict. The argument is a snapshot dict (as returned by get/list); its id is used.
delete()
Deletes a snapshot. The argument is a snapshot dict; its id is used.