Volumes
Volumes are FUSE-based mounts that provide shared file access across Daytona Sandboxes. They enable sandboxes to read from large files instantly - no need to upload files manually to each sandbox. Volume data is stored in an S3-compatible object store.
- multiple volumes can be mounted to a single sandbox
- a single volume can be mounted to multiple sandboxes
Create Volumes
Daytona provides volumes as a shared storage solution for sandboxes. To create a volume:
- Navigate to Daytona Volumes ↗
- Click the Create Volume button
- Enter the volume name
The following snippets demonstrate how to create a volume using the Daytona SDK:
daytona = Daytona()volume = daytona.volume.create("my-awesome-volume")const daytona = new Daytona();const volume = await daytona.volume.create("my-awesome-volume");For more information, see the Python SDK and TypeScript SDK references:
Mount Volumes
Daytona provides an option to mount a volume to a sandbox. Once a volume is created, it can be mounted to a sandbox by specifying it in the CreateSandboxFromSnapshotParams object. Volume mount paths must meet the following requirements:
- Must be absolute paths: Mount paths must start with
/(e.g.,/home/daytona/volume) - Cannot be root directory: Cannot mount to
/or// - No relative path components: Cannot contain
/../,/./, or end with/..or/. - No consecutive slashes: Cannot contain multiple consecutive slashes like
//(except at the beginning) - Cannot mount to system directories: The following system directories are prohibited:
/proc,/sys,/dev,/boot,/etc,/bin,/sbin,/lib,/lib64
The following snippets demonstrate how to mount a volume to a sandbox:
import osfrom daytona import CreateSandboxFromSnapshotParams, Daytona, VolumeMount
daytona = Daytona()
# Create a new volume or get an existing onevolume = daytona.volume.get("my-volume", create=True)
# Mount the volume to the sandboxmount_dir_1 = "/home/daytona/volume"
params = CreateSandboxFromSnapshotParams( language="python", volumes=[VolumeMount(volumeId=volume.id, mountPath=mount_dir_1)],)sandbox = daytona.create(params)
# Mount a specific subpath within the volume# This is useful for isolating data or implementing multi-tenancyparams = CreateSandboxFromSnapshotParams( language="python", volumes=[VolumeMount(volumeId=volume.id, mountPath=mount_dir_1, subpath="users/alice")],)sandbox2 = daytona.create(params)import { Daytona } from '@daytonaio/sdk'import path from 'path'
const daytona = new Daytona()
// Create a new volume or get an existing oneconst volume = await daytona.volume.get('my-volume', true)
// Mount the volume to the sandboxconst mountDir1 = '/home/daytona/volume'
const sandbox1 = await daytona.create({ language: 'typescript', volumes: [{ volumeId: volume.id, mountPath: mountDir1 }],})
// Mount a specific subpath within the volume// This is useful for isolating data or implementing multi-tenancyconst sandbox2 = await daytona.create({ language: 'typescript', volumes: [ { volumeId: volume.id, mountPath: mountDir, subpath: 'users/alice' }, ],})For more information, see the Python SDK and TypeScript SDK references:
Work with Volumes
Daytona provides an option to read from and write to the volume just like any other directory in the sandbox file system. Files written to the volume persist beyond the lifecycle of any individual sandbox.
The following snippet demonstrate how to read from and write to a volume:
# Write to a file in the mounted volumewith open("/home/daytona/volume/example.txt", "w") as f: f.write("Hello from Daytona volume!")
# When you're done with the sandbox, you can remove it# The volume will persist even after the sandbox is removedsandbox.delete()import fs from 'fs/promises'
// Write to a file in the mounted volumeawait fs.writeFile('/home/daytona/volume/example.txt', 'Hello from Daytona volume!')
// When you're done with the sandbox, you can remove it// The volume will persist even after the sandbox is removedawait daytona.delete(sandbox1)For more information, see the Python SDK and TypeScript SDK references.
Get a Volume by name
Daytona provides an option to get a volume by its name.
daytona = Daytona()volume = daytona.volume.get("my-awesome-volume", create=True)print(f"{volume.name} ({volume.id})")const daytona = new Daytona()const volume = await daytona.volume.get('my-awesome-volume', true)console.log(`Volume ${volume.name} is in state ${volume.state}`)For more information, see the Python SDK and TypeScript SDK references:
List Volumes
Daytona provides an option to list all volumes.
daytona = Daytona()volumes = daytona.volume.list()for volume in volumes: print(f"{volume.name} ({volume.id})")const daytona = new Daytona()const volumes = await daytona.volume.list()console.log(`Found ${volumes.length} volumes`)volumes.forEach(vol => console.log(`${vol.name} (${vol.id})`))For more information, see the Python SDK and TypeScript SDK references:
Delete Volumes
Daytona provides an option to delete a volume. Deleted volumes cannot be recovered.
The following snippet demonstrate how to delete a volume:
volume = daytona.volume.get("my-volume", create=True)daytona.volume.delete(volume)const volume = await daytona.volume.get('my-volume', true)await daytona.volume.delete(volume)For more information, see the Python SDK and TypeScript SDK references:
Limitations
Since volumes are FUSE-based mounts, they can not be used for applications that require block storage access (like database tables). Volumes are generally slower for both read and write operations compared to the local sandbox file system.