Functions
GetDefaultVolume()
FS(). The local backend returns ErrUnsupportedOperation; it never substitutes a directory from the caller’s machine.
CreateVolume()
Example
Example
*Volume with its name and host path. Configure the kind, quota, disk size, and labels with option functions. Returns ErrVolumeAlreadyExists if a volume with the given name already exists.
Parameters
ctxcontext.Contextnamestringopts…VolumeOptionReturns
Name and Path.GetVolume()
Example
Example
ErrVolumeNotFound if no such volume exists.
Parameters
ctxcontext.ContextnamestringReturns
ListVolumes()
Example
Example
Parameters
ctxcontext.ContextReturns
RemoveVolume()
Example
Example
Parameters
ctxcontext.ContextnamestringVolume
Returned by CreateVolume()
A named persistent volume.v.Name()
v.Path()
v.FS()
Example
Example
*VolumeFs for direct file operations. Local calls use the managed host directory; Cloud calls use the authenticated volume API.
Returns
v.Remove()
Example
Example
RemoveVolume(ctx, v.Name()).
VolumeHandle
Metadata reference for a named volume. Obtain viaGetVolume or ListVolumes.
Returned by GetVolume() · ListVolumes()
AVolumeHandle is the metadata reference returned by GetVolume and ListVolumes.
h.Name()
h.Path()
h.Kind()
VolumeKindDir or VolumeKindDisk.
Returns
h.QuotaMiB()
nil if unlimited.
h.UsedBytes()
h.CapacityBytes()
nil for directory volumes.
h.DiskFormat()
nil for directory volumes.
h.DiskFstype()
nil for directory volumes.
h.Labels()
h.CreatedAt()
time.Time value if unknown.
h.FS()
*VolumeFs for direct host-side file operations on this volume.
Returns
h.Remove()
RemoveVolume(ctx, h.Name()).
VolumeFs
Returned by Volume.FS() · VolumeHandle.FS()
Host-side filesystem operations for a named volume.vfs.Root()
vfs.Read()
Parameters
relPathstringReturns
vfs.ReadString()
vfs.Write()
0o644.
Parameters
relPathstringdata[]bytevfs.WriteString()
0o644.
vfs.Mkdir()
0o755).
vfs.Remove()
vfs.RemoveAll()
vfs.Exists()
Returns
true if a file or directory exists at the path.Options
Functional options passed toCreateVolume, plus the Mount factory helpers that attach a volume, bind mount, tmpfs, or disk image to a sandbox via WithMounts.
WithVolumeKind()
VolumeKindDir (default) and VolumeKindDisk.
Parameters
kindVolumeKindWithVolumeSize()
VolumeKindDisk.
Parameters
mebibytesuint32WithVolumeQuota()
Parameters
mebibytesuint32WithVolumeLabels()
Parameters
labelsmap[string]stringMount
Mount.Bind()
MountOptions.QuotaMiB to bound how much the guest may write beyond the host directory’s existing contents, overriding the runtime’s protective default. Returns a MountConfig for use with WithMounts.
Parameters
hostPathstringoptsMountOptionsExample
Example
Mount.Named()
Example
Example
CreateVolume). Returns a MountConfig.
Parameters
namestringoptsMountOptionsMount.NamedWith()
Example
Example
NamedVolumeOptions.Mode accepts "existing" (default), "create", or "ensure-exists". Mode: "create" fails when the named volume already exists. Mode: "ensure-exists" creates the volume if it is missing and reuses a compatible existing volume; it errors when the existing volume has a different kind, quota, or capacity than requested, and never mutates existing volume metadata.
Parameters
namestringoptsMountOptionsnamedOptsNamedVolumeOptionsMount.Tmpfs()
Example
Example
MountConfig.
Parameters
optsTmpfsOptionsMount.Disk()
Example
Example
MountConfig.
Parameters
hostPathstringoptsDiskOptionsMountConfig
Mount configuration produced by theMount factory.
Returned by Mount.Bind() · Mount.Named() · Mount.NamedWith() · Mount.Tmpfs() · Mount.Disk()
mount.Bind
string
Host path for bind mounts
mount.Named
string
Volume name for named mounts
mount.NamedMode
string
Provisioning mode for named mounts ("existing", "create", "ensure-exists")
mount.NamedKind
string
Kind for provisioned named mounts ("dir" or "disk")
mount.QuotaMiB
uint32
Quota in MiB for provisioned directory volumes
mount.Tmpfs
bool
Set for tmpfs mounts
mount.Disk
string
Host path for disk images
mount.Format
string
Disk format
mount.Fstype
string
Inner filesystem type
mount.Readonly
bool
Whether the mount is read-only
mount.Noexec
bool
Whether direct execution from the mount is disabled
mount.Nosuid
bool
Whether setuid/setgid elevation from files on the mount is ignored
mount.Nodev
bool
Whether device files on the mount are ignored
mount.SizeMiB
uint32
Size limit for tmpfs / capacity for provisioned disk volumes
mount.StatVirtualization
StatVirtualization
Per-mount stat-virtualization policy (bind / named only)
mount.HostPermissions
HostPermissions
Per-mount host-permission propagation policy (bind / named only)
mount.Owner
*MountOwner
Guest owner fallback for host files without a per-file stat override (bind / directory-backed named only)
mount.Kind()
Returns
MountKind
Types
ErrPathEscape
VolumeFs method when relPath is absolute, contains a .. sequence that resolves outside the volume root, or otherwise escapes the volume’s directory after filepath.Clean.
Returned by VolumeFs methods
VolumeConfig
The config struct populated byVolumeOption functions. Most callers go through CreateVolume(ctx, name, opts...); VolumeConfig is exported for callers that prefer to construct one directly.
Mutated by VolumeOption
VolumeOption
CreateVolume. Constructed by the WithVolume* helpers.
Used by CreateVolume()
VolumeKind
Used by VolumeConfig · WithVolumeKind() · VolumeHandle.Kind()
MountKind
mount.Kind().
Returned by MountConfig.Kind()
MountOptions
Tuning struct forMount.Bind, Mount.Named, and Mount.NamedWith. StatVirtualization, HostPermissions, and Owner are virtiofs-only; owner is rejected for disk-backed named volumes and when stat virtualization is off. Zero policy values preserve the conservative defaults (strict, private), while a nil owner keeps the runtime fallback identity.
Used by Mount.Bind() · Mount.Named() · Mount.NamedWith()
MountOwner
An inseparable guest ownership pair used byMountOptions.Owner. UID and GID may include zero; using a pointer to MountOwner keeps an unset owner distinct from root.
NamedVolumeOptions
Tunes sandbox-time named volume provisioning forMount.NamedWith.
Used by Mount.NamedWith()
TmpfsOptions
Tuning struct forMount.Tmpfs.
Used by Mount.Tmpfs()
DiskOptions
Tuning struct forMount.Disk.
Used by Mount.Disk()