Volume
Named volumes are managed by microsandbox and stored at~/.microsandbox/volumes/<name>/. They persist independently of any sandbox.
Static methods
Volume.create()
| Name | Type | Description |
|---|---|---|
| name | str | Volume name (required) |
| quota_mib | int | None | Maximum storage size in MiB |
| labels | dict[str, str] | None | Metadata labels |
| Type | Description |
|---|---|
Volume | Created volume with name and path properties |
Volume.get()
| Name | Type | Description |
|---|---|---|
| name | str | Volume name |
| Type | Description |
|---|---|
VolumeHandle | Volume handle |
Volume.list()
| Type | Description |
|---|---|
list[VolumeHandle] | All volumes |
Volume.remove()
| Name | Type | Description |
|---|---|---|
| name | str | Volume name |
Volume instance properties
| Property | Type | Description |
|---|---|---|
| name | str | Volume name |
| path | str | Host path to the volume directory |
Mount config factories
Static factory methods onVolume for creating mount configurations used in sandbox volume config.
Volume.bind()
| Name | Type | Description |
|---|---|---|
| path | str | Directory path on the host |
| readonly | bool | Mount as read-only |
| Type | Description |
|---|---|
dict | Mount configuration dictionary |
Volume.named()
Volume.create()).
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | Volume name |
| readonly | bool | Mount as read-only |
| Type | Description |
|---|---|
dict | Mount configuration dictionary |
Volume.tmpfs()
| Name | Type | Description |
|---|---|---|
| size_mib | int | None | Maximum size in MiB |
| readonly | bool | Mount as read-only |
| Type | Description |
|---|---|
dict | Mount configuration dictionary |
VolumeHandle
Handle to an existing named volume, returned byVolume.get() and Volume.list().
| Property / Method | Type | Description |
|---|---|---|
| name | str | Volume name |
| quota_mib | int | None | Storage quota in MiB |
| used_bytes | int | Current disk usage in bytes |
| labels | dict[str, str] | Metadata labels |
| created_at | float | None | Creation timestamp (ms since epoch) |
| fs | VolumeFs | Host-side filesystem handle |
| remove() | (async) None | Delete this volume |
VolumeFs
Host-side filesystem operations on a named volume. Obtained via thefs property on VolumeHandle. These operations run directly on the host filesystem - no running sandbox is required.
read()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
| Type | Description |
|---|---|
bytes | File contents as raw bytes |
read_text()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
| Type | Description |
|---|---|
str | File contents as a string |
write()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
| data | bytes | File content |
list()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
| Type | Description |
|---|---|
list[FsEntry] | Directory entries |
mkdir()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
remove_file()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
exists()
| Name | Type | Description |
|---|---|---|
| path | str | Path relative to the volume root |
| Type | Description |
|---|---|
bool | True if the path exists |
Types
MountConfig
Frozen dataclass representing a mount configuration.| Field | Type | Default | Description |
|---|---|---|---|
| kind | MountKind | - | Type of mount (required) |
| bind | str | None | None | Host path for bind mounts |
| named | str | None | None | Volume name for named mounts |
| size_mib | int | None | None | Size limit for tmpfs mounts |
| readonly | bool | False | Whether the mount is read-only |
MountKind
String enum representing the type of mount.| Value | Description |
|---|---|
"bind" | Host bind mount |
"named" | Named volume mount |
"tmpfs" | In-memory filesystem |