Shaf Lab

Micro-VMs

Lightweight virtual machines that isolate a process more tightly than a container.

A micro-VM is a lightweight virtual machine that isolates a process more tightly than a container, because it has its own kernel and virtual hardware. Systems in this family start quickly enough to use for short jobs, while still giving you a stronger boundary than a shared-kernel container. You reach for them when you want to run untrusted or agent-written code without sharing the host's kernel.

For agent work, a micro-VM is a good sandbox for compiling, installing packages, or executing generated programs. You can grant a narrow network, a fresh disk, and a short lifetime, then throw the machine away. Containers still win when you want density and a familiar image, and when the code is trusted.

The operational costs are image management, startup time, and the policy around devices and networking. A micro-VM that still mounts your home directory is not isolated. Be explicit about what is inside the guest and what is not.

If a job only needs to evaluate an expression in a language isolate, you may not need a VM at all. Use the heaviest isolation that the risk actually calls for, and no more.