DaytonaDocs

VolumeService

Create and manage persistent volumes.

VolumeService manages persistent volumes: named, shareable directory trees that outlive any single sandbox. Attach a volume at sandbox creation via volumes: [...]; the sandbox works on a private scratch copy whose changes are committed back in the background, so they survive teardown and are visible to the next sandbox that attaches the same volume. Obtain the service as daytona.volume. See the volumes guide.

create()

Creates a volume. Volumes are ready immediately after creation.

TypeScript
create(name: string, sizeGb?: number): Promise<Volume>
ParameterTypeDefaultDescription
namestringVolume name (unique within the project).
sizeGbnumberOptional size in GiB; server default applies when omitted.

Returns: the Volume DTO (id, name, size_gb, state, timestamps).

TypeScript
const vol = await daytona.volume.create('datasets', 50)

get()

Fetches a volume by id or name. With create set to true, a missing volume is created on the fly — the Daytona-style get-or-create pattern.

TypeScript
get(nameOrId: string, create = false): Promise<Volume>
ParameterTypeDefaultDescription
nameOrIdstringVolume id or name.
createbooleanfalseCreate the volume if it does not exist.

Returns: the Volume DTO. Throws: DaytonaNotFoundError when missing and create is false.

TypeScript
const vol = await daytona.volume.get('datasets', true)

list()

Lists the project's volumes. Deleted volumes are excluded unless includeDeleted is true.

TypeScript
list(includeDeleted = false): Promise<Volume[]>

Returns: an array of Volume DTOs. Volume state is one of ready, deleting, deleted, or error.

delete()

Deletes a volume. Accepts a Volume DTO (its id is used) or a plain id/name string. Fails with a conflict if the volume is attached to a live sandbox.

TypeScript
delete(volume: Volume | string): Promise<void>

Throws: DaytonaConflictError if the volume is currently attached.

TypeScript
await daytona.volume.delete('datasets')

Attaching volumes: VolumeMount

Attach volumes at sandbox creation with VolumeMount objects in volumes. A sandbox with volumes cold-boots (it bypasses snapshot-resume templates).

TypeScript
const sandbox = await daytona.create({
  image: 'node:22-slim',
  volumes: [{ volumeId: 'datasets', mountPath: '/data' }],
})
FieldTypeDefaultDescription
volumeIdstringVolume id or name (resolved server-side).
mountPathstringAbsolute in-sandbox mount path.
subpathstringMount a subdirectory of the volume instead of its root.

See using volumes for commit semantics and concurrency notes.

On this page