Skip to main content
On microsandbox cloud: Volumes use fast block storage managed by the platform. Every organization automatically gets an undeletable host volume: think of it as the disk of the one computer all its sandboxes run on, and it is what bind and disk-image mounts resolve against.
Volumes give a sandbox persistent or shared storage by mounting host data, managed storage, disk images, or in-memory filesystems into the guest. Mounts provide direct filesystem access and are significantly faster than the filesystem API, which transfers files individually, so they are preferable for anything beyond ad-hoc reads and writes. Choose bind mounts, named volumes, disk-image volumes, or tmpfs. Local sandboxes also support owned volumes: private storage that lives and dies with the sandbox.

Temporary files

For OCI sandboxes with a disk-backed root, /tmp uses the root disk unless you explicitly mount another filesystem there. Large package downloads and build files therefore consume disk capacity and leave guest RAM available for build processes. For a new Cloud OCI sandbox that omits disk size, the writable-disk default matches requested RAM, bounded to 4–16 GiB. Explicit disk sizes and restored snapshot sizes take precedence. Disk-backed temporary files can survive stop/start and be included in snapshots; remove them when they are no longer needed. An explicit tmpfs mount remains available for workloads that need RAM-backed, per-boot scratch space. Existing sandbox configurations with a saved tmpfs mount retain it on restart. OCI roots explicitly configured as tmpfs keep their bounded /tmp tmpfs default.

Cloud default volume

Every cloud organization has an always-present default volume. You can read and write it directly without starting a sandbox:
microsandbox isolates the default volume to the authenticated cloud organization, and you cannot remove it. microsandbox deliberately does not support default-volume lookup on the local backend: forgetting an API key cannot expose or modify files from your machine. Named local volumes continue to live under ~/.microsandbox/volumes/ and retain their existing direct filesystem API.

Bind mounts

Mount a directory from the host directly into the sandbox. Changes inside the sandbox are reflected on the host, and vice versa.
microsandbox supports nested destinations. It canonicalizes guest paths and always applies enclosing mounts before their children. SDKs that accept unordered maps (such as Go) produce the same result regardless of map iteration order. Use --mount-file when you want to bind one host file instead of an entire directory. File mounts expose the selected host inode through an isolated one-entry filesystem. They do not hard-link or copy the source, host changes remain visible, and other files in the source directory are not part of the guest-visible share. Writable file mounts receive the same default quota as directory binds; use quota=<size> to set a smaller or larger guest-growth budget.

Owned volumes

Use an owned volume when the data belongs to one sandbox. No volume name or separate cleanup is needed. It starts empty, survives stop/start, and is removed with the sandbox. Mounting over an existing image directory hides its contents; it does not copy them into the volume.
Disk-only snapshots capture owned data too. Full snapshots and branches retain it along with execution state. Restoring or branching creates private copies automatically; no mount mapping or inheritance flag is needed, and child writes never change the source’s data. Use a named volume instead when data should outlive or be shared between sandboxes. Owned-directory snapshots retain platform-specific filesystem metadata and cannot move between Unix (macOS/Linux) and Windows. Owned disks do not have this directory-format restriction; full snapshots still require a compatible execution-state restore target.

Named volumes

microsandbox manages named volumes and stores them by default under ~/.microsandbox/volumes/<name>/. They persist independently of any sandbox, so you can create a volume, populate it, and mount it into different sandboxes over time. Named volumes can be directory-backed or disk-backed. Directory volumes mount through virtiofs. Disk volumes are raw ext4 disk images that microsandbox manages, and they mount through virtio-blk. CLI named mounts are idempotent. -v name:/path and --mount-named name:/path create a directory-backed named volume if it does not already exist, then mount it. If the volume already exists, microsandbox reuses it when the requested storage settings are compatible and errors when they are not. Use --mount-named name:/path:kind=disk,size=20G to create or reuse a disk-backed named volume from the mount flag itself. SDK named(...) mount helpers are existing-only. They fail if the named volume does not already exist. Use each SDK’s explicit named-volume mode API when you want sandbox creation to create or ensure the volume.

Create a volume

Create a disk-backed named volume when a workload needs a real guest block filesystem, such as Docker’s data root:

Mount in a sandbox

The CLI command above creates pip-cache as a directory-backed named volume if it is missing. To create or reuse a disk-backed named volume while mounting it:

Sharing and host-side access

Mount the same directory-backed named volume into multiple sandboxes when they need to share files. Use readonly on consumers that should not write. microsandbox attaches disk-backed named volumes as block devices; use one writable sandbox at a time, or read-only mounts where sharing is intended. Directory-backed named volumes are also accessible without a running sandbox, so you can pre-populate a cache or inspect output after the sandbox stops. Local volumes expose their host path directly; cloud default and managed directory volumes use the same volume filesystem API shown above. Disk-backed local volumes store guest data inside disk.raw; host filesystem helpers operate on the managed volume directory, not the filesystem inside the disk image.

Manage volumes

Disk-image volumes

Disk-image volumes attach a host disk image as a virtio-blk device and mount its inner filesystem at a guest path. Use them when you want persistent state isolated from ordinary host filesystem metadata, or when distributing a prebuilt filesystem image. The disk format defaults from the file extension (.qcow2, .raw, .vmdk; otherwise raw). microsandbox auto-detects the inner filesystem type unless you set fstype.

Tmpfs

An in-memory filesystem that disappears when the sandbox stops. Useful for scratch space, build artifacts, or anything that doesn’t need to outlive the sandbox.

Mount options

Mounts use normal Linux behavior by default: writable, executable, suid-enabled, and device-enabled. Adjust with:
  • readonly / ro when the guest should not write to the mount.
  • noexec when files on the mount should not be executed directly.
  • nosuid when setuid/setgid bits should be ignored.
  • nodev when device files should be ignored.
noexec does not stop interpreters from reading scripts from the mount, for example sh /app/src/script.sh. For stronger in-guest hardening, create the sandbox with the restricted security profile. Restricted sandboxes set no_new_privs, drop mount-admin capability from user commands, and force nosuid,nodev on user mounts. This profile is incompatible with workloads such as sudo and Docker-in-Docker.

Fallback guest ownership

Bind mounts and directory-backed named volumes normally present host files without a per-file metadata override using the sandbox user’s fallback identity. Set a mount owner when those files should consistently appear as another guest (uid, gid) pair. This changes only the guest view: it does not chown the host files or create per-file metadata overrides, and an existing per-file override still takes precedence. Both IDs are required together and may range from 0 through 4294967295. Mount owners require stat virtualization, so they cannot be combined with stat-virt=off, tmpfs, host disk images, or disk-backed named volumes. The local backend supports this policy; the cloud backend currently rejects it until ownership capability negotiation is available.

CLI syntax and flags

Most CLI mount flags use SOURCE:DEST[:OPTIONS]; --mount-owned only needs DEST[:OPTIONS]. The : before OPTIONS starts the option block, and commas separate options inside that block.

Combining mounts

A sandbox can combine host directories, individual files, named volumes, disk images, and tmpfs scratch space. In the CLI, repeat the mount flags. Ruby currently supports named-volume management, but does not expose sandbox mount configuration.

Reference

For exact volume APIs, see TypeScript, Rust, Python, or Go. For local volume management, see Volume commands.