Snapshot & Volume Management
Relevant source files
The following files were used as context for generating this wiki page:
- libs/sdk-typescript/src/Snapshot.ts
- libs/sdk-go/pkg/daytona/snapshot_service.go (Referenced via libs/sdk-go/README.md)
- apps/dashboard/src/pages/Snapshots.tsx
- apps/dashboard/src/pages/Volumes.tsx
- examples/go/snapshots_withlogstreaming/main.go
- examples/typescript/declarative-image/index.ts
- libs/sdk-go/README.md
Snapshot and Volume Management within Daytona provides the infrastructure for persistent storage and environment templating. Snapshots represent pre-configured, reusable sandbox templates containing specific images, tools, and configurations, allowing developers to instantiate identical environments rapidly. Volumes provide shared file access and persistent storage across sandboxes, ensuring data longevity beyond the lifecycle of an individual execution environment.
These systems are exposed through the Daytona API and consumed by the Dashboard UI and multi-language SDKs (Go, TypeScript, Python, Ruby), enabling both manual management and automated infrastructure-as-code workflows.
Sources: libs/sdk-typescript/src/Snapshot.ts:15-30, apps/dashboard/src/pages/Volumes.tsx:20-30, libs/sdk-go/README.md:160-175
Snapshot Management
Snapshots are the primary mechanism for distributing pre-built development environments. A Snapshot encapsulates the base image (e.g., Ubuntu, Debian), resource allocations (CPU, Memory, Disk), and specific build instructions or context files.
Snapshot Lifecycle and States
Snapshots transition through various states during creation and maintenance. The management service tracks these states to provide real-time feedback to users via log streaming.
The state machine ensures that only ACTIVE snapshots can be used to provision new sandboxes.
Sources: libs/sdk-typescript/src/Snapshot.ts:125-140, apps/dashboard/src/pages/Snapshots.tsx:115-130
Creating Snapshots
Snapshots can be created from simple image strings or via complex declarative definitions using the Image class. When using declarative images, the SDK processes local context files, uploads them to object storage, and submits the build info to the Daytona API.
| Parameter | Type | Description |
|---|---|---|
name | string | Unique identifier for the snapshot |
image | string | Image | Base image name or declarative Image object |
resources | Resources | Optional CPU, GPU, Memory, and Disk overrides |
entrypoint | string[] | Optional custom entrypoint for the container |
regionId | string | Target region for snapshot availability |
Sources: libs/sdk-typescript/src/Snapshot.ts:47-60, examples/typescript/declarative-image/index.ts:16-30
Snapshot Log Streaming
During the creation process, Daytona provides real-time build logs. This is implemented via a streaming response from the API that the SDKs expose as either a callback or a channel.
Volume Management
Volumes provide persistent, shared storage that can be mounted into sandboxes. Unlike the ephemeral storage of a standard sandbox, volumes persist until explicitly deleted.
Key Volume Operations
The Volume Service allows for lifecycle management and attachment. Through the Dashboard, users can perform bulk actions and monitor volume usage.
- Creation: Instantly provisions shared storage for volume mounts.
- Listing: Retrieves all volumes within the selected organization.
- Deletion: Permanently removes the volume and its associated data.
- Last Used Tracking: The system tracks when volumes were last accessed to assist in cleanup.
Sources: apps/dashboard/src/pages/Volumes.tsx:80-120, libs/sdk-go/README.md:175-185
Dashboard Interaction Flow
The Dashboard UI manages volumes through an asynchronous notification system to ensure the UI stays in sync with background operations.
Data Structures
Snapshot Definition
The Snapshot type represents the core data model for a pre-configured environment.
export type Snapshot = {
id: string;
organizationId: string;
name: string;
imageName: string;
state: SnapshotState;
size: number;
cpu: number;
mem: number;
disk: number;
createdAt: Date;
lastUsedAt: Date;
}
Sources: libs/sdk-typescript/src/Snapshot.ts:17-40
Volume DTO
The Volume Data Transfer Object (DTO) used by the API and Dashboard.
| Field | Type | Description |
|---|---|---|
id | string | Unique internal ID |
name | string | User-assigned name |
state | VolumeState | Current state (CREATED, PENDING_DELETE, etc.) |
lastUsedAt | string | ISO timestamp of last sandbox attachment |
Sources: apps/dashboard/src/pages/Volumes.tsx:60-75
Conclusion
Snapshot & Volume Management forms the backbone of Daytona's "environment as code" philosophy. By allowing developers to define complex images via Snapshots and persist data through Volumes, Daytona provides a balance between the speed of ephemeral containers and the reliability of persistent development machines. These services are integrated across all client layers, from CLI and SDKs to the web-based Dashboard.
Sources: libs/sdk-typescript/src/Snapshot.ts, apps/dashboard/src/pages/Snapshots.tsx