Skip to main content
A running sandbox does not need to be replaced just because its workload changes. modify can resize the VM, update host-side metadata, rotate existing secrets, and change the defaults used by future commands while the sandbox stays up.
A terminal changes CPU, memory, and a label while the sandbox remains running

What can modify change?

The live paths come first, but modify also plans changes that need a restart or the next start: The default policy applies only changes that can complete without restarting. If a patch contains one restart-required change, the whole patch is rejected and the old configuration stays intact.

Modify a running sandbox

This patch doubles the running sandbox’s CPU and memory and updates a label in the same operation:
The result is a modification plan showing what changed and whether each change was applied. CPU and memory can take a moment to converge inside the guest, but the new host limits are enforced immediately and the workload continues running.

Reserve resize headroom

Live growth needs capacity reserved when the VM boots. Set max_cpus and max_memory above the starting allocation when you create a sandbox that may need to scale:
The sandbox starts with two vCPUs and 1 GiB of memory, but it can grow live to eight vCPUs and 4 GiB. The ceilings default to the starting size, so omitting them leaves no live growth headroom. Reserving headroom is cheap: spare vCPUs stay parked, and spare memory is backed only when the guest uses it. You can lower CPU or memory live without pre-planning, then grow back up to the booted ceiling later.

Preview before applying

Use a dry run when a patch mixes settings or you are unsure whether a restart is needed:
The planner classifies every requested field before it changes anything:

Live paths in detail

CPU and memory

Raise or lower CPU and memory while the workload runs:
Use msb ps to see allocation as effective / max, and msb metrics to check real usage before resizing. The apply result reports applied, converging, guest-refused, or failed for each resource so automation can wait for the guest to settle.

Labels

Labels are host-side metadata, so adding, changing, or removing one is immediate:
Running guest processes do not change. The new labels are available to listing, selection, metrics attribution, and other host-side workflows. See Labels for naming and cardinality guidance.

Environment and workdir

Environment and workdir updates require no restart, but they affect only commands started after the patch:
Processes that were already running keep their original environment and working directory.

Secrets

Rotating the value of an existing secret is live because substitution happens at the host network boundary. Guest code keeps using the same placeholder while microsandbox begins injecting the new value:
Adding a new secret or changing its guest-visible placeholder requires a restart because existing processes cannot receive a new placeholder. Removing a secret does not require recreating the sandbox. See Secrets for sources, host allow lists, and storage behavior.

Changes that need a boot boundary

Some settings define VM capacity or disk layout and cannot change in place:
--next-start saves the desired configuration without touching the running VM. --restart stops and starts the sandbox only when the patch needs it. The default policy does neither and rejects restart-required changes. Root disk resizing remains conservative: managed and flat OCI disks grow only, tmpfs can grow or shrink at the next boot, and user-supplied disk images are never resized by microsandbox. Named volume and mount capacity is managed where that storage is defined. See Volumes and Images for the storage model.

Reference

For every CLI flag and result state, see msb modify. The SDK sandbox references expose the same planner and policies for Rust, TypeScript, Python, and Go.