On this page · 13 min
Why a container isn't enough for code you didn't write
A container isn't enough because the code inside it talks to the same kernel as everything else on the host. Say your product answers questions about spreadsheets. A user uploads a file, the model writes Python to analyse it, and your backend runs that Python in a Docker container. One day a file arrives with a cell whose text reads like an instruction to the model. The code the model writes next reads the environment and probes the network when it should be summing a column. Nobody on your team wrote or read that code before it ran.
Code like that can hurt you in two ways: by using what the container can already reach, which a later section covers, or by breaking out to the host. A container and a microVM differ on the break-out.
What stands between that code and your host is the Linux kernel. A container is an ordinary process that the kernel shows a private view of files, processes and the network (namespaces), with a cap on the CPU and memory it may use (cgroups). In the words of the Docker docs, "It's still a process, so every container on a machine shares that machine's kernel." Every system call the code makes, which is how a program asks the operating system to open a file or send a packet, goes to the kernel that also runs your host and every other container on it.
Even in a container set up well, with no extra privileges and no Docker socket mounted, that leaves two kinds of bug to break out through. The first is a bug in the container runtime, the program that sets the container up. In 2024 the runtime runc leaked an internal file descriptor into new containers, which gave code inside a way to the host's filesystem. The runc advisory lists the fix in version 1.1.12. The second is a bug in the kernel itself. In 2022 a buffer overflow in the kernel's filesystem code, CVE-2022-0185, let an unprivileged local user escalate their privileges. To the kernel, the process in your container is a local user, so a flaw like that can be reached from any container that is allowed to make the call.
Whether this matters to you depends on whose code runs. If you wrote and reviewed it, nothing inside the container is trying to get out, and a container is fine. If a model or a user wrote it, the shared kernel is a risk, and the risk grows with what else is on the host: other users' workloads, or your keys.
What is a microVM?
A microVM is a virtual machine that has its own kernel and almost no emulated hardware. Modern CPUs have virtualization features that let a second operating system, the guest, run directly on the processor inside memory the host has walled off. A hypervisor is the software that uses those features, and on Linux it is usually KVM, which is part of the kernel. KVM looks after the CPU and memory. The program that creates the VM, loads its kernel and plays the part of its disk and network card is called a virtual machine monitor, or VMM.
A general-purpose VMM imitates a whole PC, with firmware, a device bus, graphics and USB, so that any operating system can boot on it. A microVM monitor leaves nearly all of that out. It loads a Linux kernel directly and gives the guest a handful of devices, such as a network card, a disk and a serial console. So there is less to start, which makes the VM fast, and there is less device code, which is the part of the monitor a guest can attack.
Firecracker, the monitor AWS built for Lambda, publishes how small that gets. Firecracker's specification promises at most 125 ms from the start call to the first program starting inside the guest, measured with a minimal kernel and root filesystem and the serial console off. It also promises at most 5 MiB of memory overhead for the monitor of a guest with 1 CPU and 128 MiB of RAM. Now put the spreadsheet code in a microVM. Its system calls go to the guest kernel, and that kernel belongs to this one workload. A kernel bug gives the code control of the guest, which it already had. To reach your host it has to break KVM or one of those few devices, and then get out of the monitor process, which is itself confined. Firecracker, for example, drops its privileges at start and runs under a kernel filter that limits which system calls it may make.
What is Firecracker, and what else runs microVMs?
Firecracker is a VMM that runs microVMs on KVM. It was developed at Amazon Web Services for Lambda and Fargate, it is written in Rust, and it runs on Linux hosts with 64-bit x86 or Arm CPUs. It is open source under the Apache 2.0 licence and free to use, so what you pay for is the hosts it runs on. Firecracker is the program that runs a VM, not the VM itself.
Other monitors draw the same boundary, a guest kernel behind the CPU's virtualization hardware:
- Cloud Hypervisor is another open-source VMM written in Rust on KVM. It can pass host devices through to the guest, which is how a VM gets direct use of hardware such as a GPU.
- QEMU's microvm machine type is a cut-down machine in the QEMU emulator, which its docs describe as "inspired by Firecracker".
- Kata Containers is not a monitor. It wraps a VM so that Kubernetes can start it like a container, with QEMU, Cloud Hypervisor or Firecracker underneath.
gVisor is often listed next to these, but it is not a microVM. Its own docs call it "an application kernel, not a virtual machine hypervisor". It answers a container's system calls in a normal program, so the code never calls the host kernel directly, and it boots no guest kernel. That is a stronger wall than a plain container, and it works on hosts without KVM. The price is compatibility, because gVisor doesn't implement every system call, and speed on work that makes many of them.
Companies that sell microVMs also write their own monitors when none of these fit. boxd machines run on our own VMM, written in Rust on KVM. Docker built one for Docker Sandboxes, because it needed macOS and Windows hosts as well as Linux. Others take a monitor off the shelf: E2B runs each sandbox in a Firecracker microVM, and in June 2026 AWS introduced Lambda MicroVMs, which run on Firecracker, "for isolated execution of user and AI-generated code". Which monitor a provider uses matters less than whether there is a guest kernel at all.
MicroVM vs container, side by side
A container is lighter and runs anywhere, and a microVM has the stronger wall and a whole Linux inside it.
| Container | MicroVM | Full VM | |
|---|---|---|---|
| Kernel | The host's, shared | Its own Linux kernel | Its own, any operating system |
| What separates it from the host | The host kernel's namespaces and cgroups | The CPU's virtualization hardware and a small monitor | The same hardware and a monitor that imitates a whole PC |
| What an escape takes | One bug in the runtime or the kernel | A bug in the hypervisor or one of a few devices, then a way out of the confined monitor | The same, with many more devices to find a bug in |
| Start | As fast as a process starts | A kernel boot: 125 ms or less for Firecracker, measured on the host | Firmware, then a full operating system boot |
| Memory | What the process uses | A guest kernel and its own allotment of RAM per VM | A full operating system per VM |
| Where it runs | Any Linux host | Hosts with a hypervisor, which on Linux means KVM | Hosts with a hypervisor |
| Docker inside it | Needs extra privileges | Works, because the guest is a full Linux | Works |
The container wins every row about cost. It starts faster, uses only the memory its process needs and runs on any Linux host. For code you trust, these advantages cost you nothing.
The microVM wins the row that matters for code you don't trust, which is the wall. It also gives the code a complete Linux, so an agent can build and run containers of its own. If you rent a sandbox instead of running one, you are still in one of these columns, and the word "sandbox" doesn't tell you which. Ask which one you're getting. A boxd machine is always the middle column. Daytona offers container sandboxes and VM sandboxes, and Modal runs sandboxes on gVisor or in a VM.
What a microVM costs you
On Linux, a microVM costs you a host that has KVM, and many hosts don't. The details here are Firecracker's, and other monitors ask for much the same. (If you rent, the provider carries the first two costs, but the note on boot times still applies.)
Firecracker needs read and write access to /dev/kvm. That device exists on bare-metal servers, and on cloud VMs only with nested virtualization, which means a VM is allowed to run VMs of its own. AWS supports it on a list of instance families, and the AWS guide shows how to switch it on per instance. Google Cloud excludes several machine types and warns that CPU-bound work in a nested VM may run 10% or more slower. Firecracker's guide gives the check to run:
[ -r /dev/kvm ] && [ -w /dev/kvm ] && echo "OK" || echo "FAIL"It prints OK if your user can use KVM, and FAIL if KVM is missing or you have no access to it.
The second cost is everything a container runtime did for you. Firecracker boots an uncompressed Linux kernel and a root filesystem image that you supply, and you wire up each VM's network on the host. Each VM also gets its own allotment of RAM, kernel included, so a host holds fewer microVMs than it would hold containers.
Read boot times with care. Firecracker's 125 ms describes a VM with a minimal kernel, timed on the host that runs it. A hosted service's create time, measured from your client, also includes its API and the network. So don't compare a provider's create time with a monitor's boot time.
What a microVM leaves open
A microVM protects the host from the code. It doesn't decide what the code can reach from inside, which is the other way the spreadsheet code can hurt you. That code has no need to escape if the VM holds an API key in an environment variable and the network is open. It reads the key and posts it to a server of its choosing.
Whichever boundary you pick, three more things need an answer. The first is where the code can connect: a list of allowed hosts, enforced outside the VM. A list limits where data can go, but it doesn't stop data leaving to an allowed host that accepts writes. The second is what secrets the code holds. It should be able to use a key without being able to read it, which means the real value lives outside the VM. The third is how long the VM lives. An agent's task can run for hours, and its files and running processes are its context, so check how long a sandbox may run before you build a long task on it.
How much of this you need depends on whether you sandbox only the code the agent runs or the whole agent. If only a code-execution tool runs in the VM, the loop and the keys stay in your service and the VM can be short-lived and empty. If the whole agent lives there, it needs a full Linux for hours and tight control of the network. We've written more about both: sandboxes with a hardware boundary, and agents on their own machines.
When is a microVM better than a container?
A microVM is better whenever the answer to "whose code?" is not "ours", and it matters most when the host also serves other users or holds your keys. The hosts you have then decide how you get one.
- Your code: keep the container. Nothing inside is trying to get out.
- Untrusted code, on hosts without KVM: rent a microVM, or run the container on gVisor if your workload runs without the system calls gVisor lacks.- Untrusted code, and you have KVM hosts and people to run them: run your own microVMs with Firecracker or Cloud Hypervisor. You get the wall and take on images, networking and host operations.
- Untrusted code, and you'd sooner not run hosts: rent a microVM. Ask the provider three things: what the kernel boundary is, how the network is limited and where secrets live.
- Windows, or hardware your microVM monitor can't pass through: a full VM.
For a hosted microVM you can use boxd or E2B. Both answer the first question the same way: the code gets a kernel of its own, so the spreadsheet code never makes a system call to a kernel another customer shares. Our answers to the other two are these. Each boxd machine has an egress allowlist that limits which hosts it can reach. With host-bound secrets the machine holds only a placeholder, and the real value is swapped in on HTTPS requests to the hosts you named. Code in the machine can still use the key on those hosts, but it can't read it or take it elsewhere.
If you can't vouch for the code, give it a kernel of its own. To try that on one machine, install the CLI:
curl -fsSL https://boxd.sh/downloads/install.sh | shThen create a sandboxed machine and limit where it can connect:
boxd machine new agent-task --isolated
boxd machine egress agent-task pypi.org,files.pythonhosted.orgThe first command creates a machine that can't reach your other machines and carries none of your logins or credentials. It can still reach the internet, so the second replaces its allowlist, and the machine now reaches the Python package index and nothing else. Both commands are in the command reference, and the agent sandbox page shows how to lock a machine down further.
Frequently asked
- What is a microVM?
- A microVM is a small virtual machine with its own Linux kernel. A stripped-down virtual machine monitor loads the kernel directly and gives the guest only a few devices, such as a network card and a disk, so the VM starts quickly and has little device code a guest could attack.
- What are the key differences between Docker and Firecracker microVMs?
- A Docker container is a process that shares the host's kernel, so one bug in the container runtime or the kernel can let code out. A Firecracker microVM has its own kernel behind the CPU's virtualization hardware. The container starts faster, uses less memory and runs on any Linux host. The microVM needs a host with KVM, plus a kernel and a disk image.
- Is Firecracker open source, and is it free?
- Yes. Firecracker is open source under the Apache 2.0 licence and free to use. You pay for the hosts it runs on, which need KVM.
- Does Firecracker use KVM?
- Yes. Firecracker is a virtual machine monitor that uses KVM, the hypervisor in the Linux kernel, to create and run microVMs. It needs read and write access to /dev/kvm, which exists on bare-metal servers and on cloud VMs with nested virtualization switched on.
- What are some alternatives to Firecracker?
- Cloud Hypervisor is another open-source monitor written in Rust on KVM. QEMU has a cut-down microvm machine type. Kata Containers wraps a VM so container tools can start it, using QEMU, Cloud Hypervisor or Firecracker underneath. gVisor is sometimes listed too, but it is a kernel that runs as a normal program, not a microVM.
- When is a container enough?
- When you wrote and reviewed the code and it runs on your own hosts. Nothing inside is trying to get out, and a container starts faster and uses less memory than a microVM. Use a microVM when a model or a user wrote the code.



