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.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.

Python
def create(
    params: CreateSnapshotParams,
    on_logs: Callable[[str], None] | None = None,
    timeout: int = 0,
) -> Dict[str, Any]
ParameterTypeDefaultDescription
paramsCreateSnapshotParamsSee fields below.
on_logsCallable[[str], None]NoneCalled with progress messages as the snapshot changes state.
timeoutint0Seconds to wait for a terminal state; 0 waits indefinitely.

CreateSnapshotParams fields:

FieldTypeDefaultDescription
namestrSnapshot name (used later in daytona.create(snapshot=name)).
imagestrNoneRegistry ref to alias/cache, e.g. python:3.12-slim. Mutually exclusive with dockerfile.
dockerfilestrNoneInline Dockerfile to build. Must be self-contained — no COPY/ADD of local files. Mutually exclusive with image.
resourcesResourcesNoneDefault cpu/memory/disk for sandboxes created from this snapshot.
entrypointList[str]NoneEntrypoint 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.

Python
from rlp import CreateSnapshotParams
 
snap = daytona.snapshot.create(
    CreateSnapshotParams(name="py-base", image="python:3.12-slim"),
    on_logs=print,
)
sandbox = daytona.create(CreateSandboxFromSnapshotParams(snapshot="py-base"))

See image sources for Dockerfile-build details.

get()

Fetches a snapshot by name or id.

Python
def get(name_or_id: str) -> Dict[str, Any]

Returns: the snapshot dict, including state (pending, building, active, error, or build_failed). Raises: DaytonaNotFoundError if it does not exist.

list()

Lists snapshots, paginated.

Python
def list(page: int | None = None, limit: int | None = None) -> Dict[str, Any]
ParameterTypeDefaultDescription
pageintNonePage number (1-based).
limitintNoneItems per page.

Returns: {"items": [...], "total": int, "page": int, "total_pages": int}.

Python
page = daytona.snapshot.list(page=1, limit=20)
for snap in page["items"]:
    print(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.

Python
def activate(snapshot: Dict[str, Any]) -> Dict[str, Any]

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.

Python
def delete(snapshot: Dict[str, Any]) -> None
Python
snap = daytona.snapshot.get("py-base")
daytona.snapshot.delete(snap)

On this page