Skip to content
← all posts

MicroVM vs container for agents?

Why kernel boundaries matter when language models write and run untrusted code.

Cocona L5 min read

MicroVM vs container for agents?

You want an AI agent to write and run untrusted code without putting your host machine or API keys at risk. Standard containers share one Linux kernel with the host, while hardware microVMs give each sandbox its own guest kernel. Pick plain containers for trusted internal services, and use a microVM whenever a model executes untrusted code.

Most teams start with docker run because Docker is already on developer laptops and packages dependencies cleanly in OCI images. That setup holds up well for backend services your team wrote and reviewed ahead of time. Once an agent starts generating commands against external repositories at runtime, process isolation and hardware virtualization behave very differently.

How containers and microVMs isolate code

A standard Linux container separates filesystem views and process trees using namespaces, cgroups, and Seccomp. Every syscall inside that container still goes to the same host Linux kernel shared with your machine and any sibling containers.

A microVM places CPU hardware virtualization (KVM on Linux or Hypervisor.framework on Apple Silicon macOS) between the workload and the host OS. Each sandbox boots its own guest kernel, keeping untrusted agent syscalls inside that virtual machine boundary.

DimensionStandard OCI containerHardware microVM
Kernel boundaryShared host Linux kernelDedicated guest kernel per sandbox
Isolation mechanismNamespaces, cgroups, SeccompHardware virtualization (KVM / Hypervisor.framework)
Escape surfaceShared host kernel syscallsHypervisor boundary and virtual devices
Daemon modelUsually requires dockerd or a runtime daemonDaemon-backed or embedded as a library (as in BoxLite)
Packaging formatStandard OCI imagesStandard OCI images inside the microVM
Best fitTrusted services and internal buildsUntrusted LLM code and YOLO coding workflows

Where shared-kernel containers fall short for agents

In Why do AI agents need a sandbox?, we compared bare-host app hooks, standard OCI containers, and microVMs. Bare-host hooks leave an agent running directly alongside your host files. Plain containers separate the filesystem view, yet they leave real exposure when the code isn't trusted.

Kernel-escape bugs are the main technical issue. If model-generated code triggers a Linux kernel bug or slips past a permissive container flag, there's no second kernel boundary stopping it from reaching the host.

On macOS, plain containers add operational drag too. Docker requires a persistent background Linux VM through Docker Desktop, which consumes memory and carries licensing costs for commercial teams. Every container on that Mac still shares that single Linux VM kernel.

Hardware isolation with standard OCI images

You still use standard OCI images when you move a workload into a microVM.

BoxLite is an Apache-2.0 open-source embeddable microVM runtime that you run and manage yourself, with no external daemon and no root privileges. You pull standard OCI images, and BoxLite boots each sandbox (called a Box) inside its own hardware-isolated microVM. It runs on Apple Silicon macOS 12+ via Hypervisor.framework, or on Linux and WSL2 via KVM (/dev/kvm). Once the OCI image is cached locally, a Box boots within seconds, close to docker run.

Host-side jailer and egress controls

A separate guest kernel doesn't protect secrets you hand straight to the sandbox if outbound traffic stays open. As covered in our YOLO coding-agent guide, BoxLite pairs the microVM with a jailed boxlite-shim child process per Box. On Linux, that jailer wraps boxlite-shim with bwrap, namespaces, chroot/pivot_root, Seccomp BPF, and cgroups v2. On macOS, it applies Seatbelt (/usr/bin/sandbox-exec with (deny default)) and rlimits.

Network rules and credentials stay on the host side too. You can cut off outbound traffic with NetworkSpec(mode="disabled"), or use NetworkSpec(mode="enabled", allow_net=[...]) with a DNS sinkhole to 0.0.0.0 and TLS SNI / HTTP Host inspection. Real keys sit behind a <BOXLITE_SECRET:name> placeholder on the host, and the host-side Secret proxy swaps in the real value only for outbound HTTPS requests matching allowed hosts.

When a plain container still makes sense

You don't need hardware virtualization for every workload. If you're deploying backend services your own team built and reviewed, standard OCI containers keep overhead low and packing simple.

Plain containers are also practical when your host blocks nested virtualization or doesn't expose /dev/kvm. Local hardware-accelerated microVMs can't boot in those environments, so you either rely on the surrounding host VM boundary or send agent execution to a managed remote runtime.

Local open-source runtime vs. BoxLite Cloud

You can deploy BoxLite either on machines you manage or through a hosted service as described in One SDK, one microVM runtime, from laptop to BoxLite Cloud.

With the open-source BoxLite runtime, you embed Boxlite.default() straight into your host process with no daemon, or run boxlite serve on your own servers. You decide whether a Box cleans up immediately after a run or keeps persistent OCI filesystem state with auto_delete=0.

When you don't want to manage host virtualization or servers yourself, Boxlite.rest(...) connects to BoxLite Cloud, a managed isolated compute environment where AI agents run code, use tools, keep state, and publish apps as services. Start with embedded BoxLite when you own the host machine, and move to BoxLite Cloud when you want BoxLite to run the compute infrastructure.