Create a named volume
Named volumes are managed by microsandbox and stored at~/.microsandbox/volumes/<name>/. You can set a storage quota at creation time.
Create, mount, and manage persistent storage
~/.microsandbox/volumes/<name>/. You can set a storage quota at creation time.
use microsandbox::Volume;
let cache = Volume::builder("pip-cache")
.quota(1024)
.create()
.await?;
use microsandbox::{Sandbox, Volume};
let cache = Volume::builder("pip-cache")
.quota(1024)
.create()
.await?;
let sb = Sandbox::builder("worker")
.image("python:3.12")
.volume("/app/src", |v| v.bind("./src").readonly())
.volume("/root/.cache/pip", |v| v.named(cache.name()))
.volume("/tmp/scratch", |v| v.tmpfs().size(100))
.create()
.await?;
use microsandbox::Volume;
let vol = Volume::get("pip-cache").await?;
vol.fs().write("/requirements.txt", "requests==2.28.0").await?;
let content = vol.fs().read_to_string("/requirements.txt").await?;
use microsandbox::Volume;
let volumes = Volume::list().await?;
Volume::remove("old-cache").await?;