A volume is storage that outlives a sandbox’s disk. Use it for data that must survive when a sandbox stops or is deleted, such as datasets, caches and work in progress.
Not available yet.
Not available yet.
Not available yet.
import { Sutra } from "@mistrive/sutra";
const sutra = new Sutra({
baseUrl: "https://anchor.jgcp.mistrivedev.com",
});
// A volume you create on its own outlives every sandbox it is attached to.
const volume = await sutra.volumes.create({ id: "datasets", sizeBytes: 20 * 1024 ** 3 });
const sandbox = await sutra.sandboxes.create({
volumes: [
{ volume: volume.name, mountPath: "/data" },
// An inline volume is created with the sandbox and deleted with it.
{ sizeBytes: 5 * 1024 ** 3, mountPath: "/cache" },
],
});
await sandbox.files.write("/data/hello.txt", "kept\n");
await sandbox.delete();
// The file is still on the volume. Attach it to another sandbox to read it.from mistrive.sutra import Sutra
sutra = Sutra(
base_url="https://anchor.jgcp.mistrivedev.com",
)
# A volume you create on its own outlives every sandbox it is attached to.
volume = sutra.volumes.create(id="datasets", size_bytes=20 * 1024**3)
sandbox = sutra.sandboxes.create(
volumes=[
{"volume": volume.name, "mount_path": "/data"},
# An inline volume is created with the sandbox and deleted with it.
{"size_bytes": 5 * 1024**3, "mount_path": "/cache"},
],
)
sandbox.files.write("/data/hello.txt", "kept\n")
sandbox.delete()
# The file is still on the volume. Attach it to another sandbox to read it.#!/usr/bin/env bash
set -euo pipefail
# Assumes you ran `sutra auth login` (see the Quickstart).
# A volume you create on its own outlives every sandbox it is attached to.
sutra volumes create datasets --size 20GiB
# An inline volume (size:path) is created with the sandbox and deleted with it.
sutra sandboxes create demo --volume datasets:/data --volume 5GiB:/cache
echo "kept" | sutra files write demo /data/hello.txt
sutra sandboxes delete demoAttach a volume
Attach volumes when you create a sandbox, in volumes. Each entry has a mountPath and either:
volume: the name of a volume you created withvolumes.create, orsizeBytes: the size of a new inline volume.
Set readOnly to mount a volume without write access.
Inline volumes
An inline volume is created with its sandbox and belongs to it. It is kept while the sandbox is stopped and deleted with the sandbox. Use it for data that one sandbox needs across stops, such as a build cache.
Volumes on their own
A volume you create with volumes.create has its own lifetime. It stays until you delete it, and you can attach it to one sandbox after another. You can also create a volume from a snapshot with sourceSnapshot.
Volumes and stop
A stopped sandbox always keeps its volumes. Files outside a volume are kept only when the sandbox’s preserved level is DISK or higher. See stop and start.