Skip to content

Volumes

View as Markdown

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:

  1. Navigate to Daytona Volumes ↗
  2. Click the Create Volume button
  3. 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")

For more information, see the Python SDK and TypeScript SDK references:

volume.get (Python SDK)

volume.get (TypeScript SDK)

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 os
from daytona import CreateSandboxFromSnapshotParams, Daytona, VolumeMount
daytona = Daytona()
# Create a new volume or get an existing one
volume = daytona.volume.get("my-volume", create=True)
# Mount the volume to the sandbox
mount_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-tenancy
params = CreateSandboxFromSnapshotParams(
language="python",
volumes=[VolumeMount(volumeId=volume.id, mountPath=mount_dir_1, subpath="users/alice")],
)
sandbox2 = daytona.create(params)

For more information, see the Python SDK and TypeScript SDK references:

CreateSandboxFromSnapshotParams (Python SDK)

CreateSandboxFromSnapshotParams (TypeScript SDK)

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 volume
with 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 removed
sandbox.delete()

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})")

For more information, see the Python SDK and TypeScript SDK references:

volume.get (Python SDK)

volume.get (TypeScript SDK)

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})")

For more information, see the Python SDK and TypeScript SDK references:

volume.list (Python SDK)

volume.list (TypeScript SDK)

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)

For more information, see the Python SDK and TypeScript SDK references:

volume.delete (Python SDK)

volume.delete (TypeScript SDK)

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.