Skip to main content
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. microsandbox supports four mount types on both backends: bind mounts, named volumes, disk-image volumes, and tmpfs.

Bind mounts

Mount a directory from the host directly into the sandbox. Changes inside the sandbox are reflected on the host, and vice versa.
Use --mount-file when you want to bind one host file instead of an entire directory.

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 managed by microsandbox and 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. Disk-backed named volumes are attached 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 from the host without a running sandbox, so you can pre-populate a cache or inspect output after the sandbox stops. Disk-backed named 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), and the inner filesystem type is auto-detected 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.

CLI syntax and flags

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

Combining mounts

Mount flags may be repeated, so a sandbox can combine host directories, individual files, named volumes, disk images, and tmpfs scratch space.