MicroVM vs Container vs gVisor: Which Isolation Should AI Agents Run In?
Compare microVMs, containers and gVisor for running AI agents. Explore differences in isolation, startup time, compatibility and resource use.
Agentastic Team
7 min read
Short answer: a container isolates processes but shares the host's kernel. gVisor puts a user-space kernel between the container and the host, so most system calls never reach the real kernel. A microVM (Firecracker, Kata Containers, Cloud Hypervisor) gives each workload its own kernel behind hardware virtualization. For AI agents running untrusted or self-written code, microVMs are the default choice, gVisor is a strong alternative when you need container ergonomics or GPUs, and plain containers are for code you already trust.
This matters more for agents than for normal software. A web server runs code you wrote. An agent runs code it wrote, often after reading instructions from a web page you've never seen.
At a glance
| Container | gVisor | MicroVM | Full VM | |
|---|---|---|---|---|
| Isolation boundary | Namespaces, cgroups, seccomp on a shared kernel | User-space kernel intercepting system calls | Hardware virtualization, own guest kernel | Hardware virtualization, own kernel and full device set |
| Shared with host | The kernel | A narrow slice of host system calls | The hypervisor | The hypervisor |
| Main escape route | A kernel vulnerability or misconfiguration | A bug in gVisor plus the narrow host interface | A hypervisor or VMM bug | A hypervisor bug |
| Startup | Well under a second | Similar to a container | Firecracker: under 125 ms | Seconds to minutes |
| Overhead | Minimal | Moderate, higher for heavy I/O and system calls | Firecracker: under 5 MiB plus the guest kernel | Hundreds of MB and up |
| Compatibility | Full Linux | Most Linux system calls, some gaps | Full Linux inside the VM | Any OS |
| GPU | Yes | Yes, for NVIDIA via gVisor's GPU proxy | Firecracker: designed without GPU passthrough | Yes, with passthrough |
| Needs hardware virtualization | No | No | Yes (KVM, so bare metal or nested virtualization) | Yes |
| Examples | Docker, Podman | Google GKE Sandbox, Modal Sandboxes | Firecracker (AWS Lambda, E2B, Vercel Sandbox), Kata Containers | QEMU/KVM, cloud instances |
Containers: fast, familiar, shared kernel
A container is just processes with blinders on. Linux namespaces give them their own view of the filesystem, network and process list. cgroups cap their CPU and memory. seccomp filters can block dangerous system calls. Docker and Podman package all of that nicely.
The catch is that every container on a host shares one kernel. The Linux kernel is huge, and a single exploitable bug in it can let code inside a container reach the host and every other container. For your own trusted services that risk is often acceptable. For code an AI agent just wrote, or downloaded from a stranger's repository, it's a thin wall.
Use containers when: the code is trusted, you control the image, and you want maximum speed and compatibility.
gVisor: a kernel in the middle
gVisor, released by Google in 2018, is an "application kernel" written in Go. It implements the Linux system call interface itself. When code in a gVisor sandbox makes a system call, gVisor handles it, and only a small, filtered set of operations ever reaches the host kernel. It plugs in as a container runtime called runsc, so it works with Docker and Kubernetes.
The benefit is a much smaller attack surface without leaving the container world. The costs are performance on workloads that make lots of system calls or do heavy I/O, and the occasional system call gVisor doesn't implement. Modal's sandboxes run on gVisor, with VMs as an option, and Google uses it for GKE Sandbox.
Is gVisor a microVM? No. It's a user-space kernel, not a virtual machine. It can use hardware virtualization features internally on some platforms, but each sandbox doesn't get its own guest kernel the way a microVM does.
Use gVisor when: you want much stronger isolation than containers, need Kubernetes-native tooling or GPU access, and can live with some overhead.
MicroVMs: their own kernel, almost no weight
A microVM is a real virtual machine with nearly everything removed. Firecracker, written in Rust and built by AWS for Lambda, emulates only five devices. Its documentation lists boot times under 125 milliseconds, under 5 MiB of overhead per VM, and up to 150 new microVMs per second on one host. A separate "jailer" process adds another layer of containment around the VMM itself.
Each microVM runs its own Linux kernel. Code inside can do anything it likes to that kernel and still has to get past the hypervisor to reach the host, which is a much smaller and better-studied surface. That's why most agent sandbox providers use them. E2B and Vercel Sandbox both run each sandbox as a Firecracker microVM.
Kata Containers give you microVM isolation with a container interface: each container or pod runs inside a lightweight VM, using Firecracker, Cloud Hypervisor or QEMU underneath.
The trade-offs: microVMs need hardware virtualization (KVM), which means bare-metal servers or cloud instances with nested virtualization. Firecracker was designed without GPU passthrough. And each VM boots a kernel, which costs a little memory.
Use microVMs when: the code is untrusted or agent-generated, many users share the hardware, or the agent needs a full Linux machine, including running Docker itself.
Lighter options worth knowing
Two other approaches show up in agent products:
- Process sandboxes (macOS Seatbelt, Linux Landlock, seccomp, bubblewrap) restrict a single process on your own computer. Coding agents like Codex CLI and Claude Code use them to keep the agent inside a project folder and off the network. Great on a laptop, not meant for multi-tenant servers.
- Language isolates and WebAssembly (V8 isolates as in Cloudflare Workers, Wasm runtimes) start in milliseconds and are very cheap, but they only run code written for that runtime, not arbitrary Linux programs.
Which should you choose for AI agents?
| Scenario | Pick | Why |
|---|---|---|
| Agent runs code it wrote, for many users on shared servers | MicroVM | Strongest boundary at low cost |
| Agent needs a full Linux box, Docker included | MicroVM | It has its own kernel |
| You need GPUs for the agent's workload | gVisor or full VM | Firecracker lacks GPU passthrough |
| Kubernetes-native platform, mixed workloads | gVisor or Kata Containers | Fits existing tooling |
| Internal tool, trusted code, your own image | Container | Fast and simple |
| Local coding agent on your laptop | Process sandbox | Protects your files without a VM |
| Short snippets in JavaScript or Wasm | Isolates or Wasm | Millisecond startup, tiny footprint |
Kubernetes users should also look at the agent-sandbox project, which manages isolated, stateful agent environments in a cluster and supports runtimes like gVisor and Kata.
The part isolation doesn't solve
Here's the uncomfortable lesson of 2026. The two most-reported AI "sandbox escapes," OpenAI's in September and Google Gemini's disclosed the same month, didn't break a container, gVisor or a hypervisor. Both went out through the network: a DNS resolver that could reach the internet, and internet access left open by mistake.
So whichever isolation you pick, pair it with:
- Deny-by-default network egress, including DNS
- No secrets inside the environment, with credentials brokered from a vault
- Limits on CPU, memory, time and actions
- Monitoring that can stop a run on its own
- Approval for anything irreversible
We go deeper on those in what is an AI agent sandbox and what is an agent VM.
Sources
- Firecracker and Firecracker on GitHub
- gVisor documentation
- Kata Containers
- Vercel Sandbox documentation, Modal Sandboxes documentation
- Kubernetes agent-sandbox
- Anthropic, Making Claude Code more secure and autonomous with sandboxing (Oct. 20, 2025)
- AWS, Introducing Strands Box (Oct. 7, 2026)
Frequently asked questions
- What is the difference between a microVM and a container?
- A container is a group of isolated processes that share the host machine's kernel, separated by Linux namespaces and cgroups. A microVM is a small virtual machine with its own kernel, isolated from the host by hardware virtualization. Containers are lighter. MicroVMs are much harder to escape, because a kernel bug inside one doesn't expose the host.
- Is gVisor a microVM?
- No. gVisor is a user-space application kernel from Google that intercepts a container's system calls and handles them itself, so most of them never reach the host kernel. It runs as a container runtime (runsc), not as a virtual machine, though it can optionally use hardware virtualization features internally.
- Which is best for running AI agent code?
- For untrusted or agent-generated code on shared infrastructure, use a microVM such as Firecracker or Kata Containers, or gVisor if you need container ergonomics or GPUs. For trusted internal tools, a hardened container is usually enough. In every case, lock down network egress and keep secrets out of the environment.
- How fast does a Firecracker microVM start?
- Firecracker's documentation lists boot times under 125 milliseconds, under 5 MiB of memory overhead per microVM, and up to 150 microVMs created per second on a single host. Restoring from a snapshot can resume a prepared environment without a full boot.
- Can I run Docker inside an AI agent sandbox?
- Inside a microVM, yes: the VM has its own kernel, so Docker runs there as it would on any Linux machine. Inside a plain container it usually requires privileged mode, which weakens isolation. gVisor supports some container-in-container setups with limits.
Keep reading
Learn
What Is an Agent VM? The Cloud Computers AI Agents Work In
An agent VM gives an AI agent an isolated computer for files, code and browsing. Learn how these environments start, pause and store work.
7 min read
Learn
What Is an AI Agent Sandbox? And Why Agents Keep Escaping Them
An AI agent sandbox limits access to files, processes, networks and credentials. Compare isolation methods and understand where their boundaries fail.
10 min read
Compare
Claude Duet vs Agentastic: Access, Tasks and Alternatives
What Claude Duet does, how its October 21 research preview works, and when to choose it or Agentastic for personal agent work.
4 min read