Memory and Device Model Differences Between a Container Process and a Firecracker Micro-VM Running an AI Agent

Firecracker gives each agent its own kernel; containers share one.

· 8 min read
Cover illustration for “Memory and Device Model Differences Between a Container Process and a Firecracker Micro-VM Running an AI Agent”
Sandbox & Runtime · November 12, 2026 · 8 min read · 1,751 words

Firecracker micro-VM isolation for AI agents gives each agent its own guest kernel, a small set of virtual devices, and hardware-enforced memory separation from the host. A container instead runs its processes on the host’s shared kernel. Those differences make Firecracker a better fit for untrusted, stateful agent work that must pause and resume, while containers remain lighter for trusted workloads.

How do you give each AI agent its own isolated kernel rather than a shared container kernel?

A container is a group of processes running on the host’s Linux kernel. Namespaces give those processes a private view of what is around them, while cgroups limit how much CPU and memory they can use. Neither creates a new kernel. When a container process makes a system call, it asks the same kernel that serves the other containers on the host. A reachable kernel exploit can therefore turn a compromise inside one container into a host-level problem.

A Firecracker micro-VM puts a guest kernel between the workload and the host. That kernel runs on virtual hardware through KVM, using Intel VT-x, AMD-V, or ARM virtualization extensions. The boundary is no longer just a policy enforced by the kernel receiving the agent’s system calls. Compromising the guest kernel does not itself compromise the host. An attacker must also defeat the virtualization boundary, whose exposed devices and memory mappings define what the guest can reach.

What Firecracker strips out of the traditional VM device model, and why that stripping is itself a security decision

A virtualization boundary needs code to handle the guest’s interaction with virtual hardware. That code is a potential attack surface. A full QEMU/KVM setup can emulate a broad hardware stack, including a PCI bus, USB controllers, and firmware discovery. Those facilities support a more general machine, but they also give a compromised guest more device-handling code to probe. Firecracker strips away that machinery because running code in the cloud does not need a virtual copy of every part of a physical computer.

The retained interface is much smaller and more focused. Firecracker provides virtio-net for networking, virtio-blk for storage, virtio-vsock for host-guest sockets, and virtio-balloon for memory ballooning. Current builds also include virtio-rng for entropy. A serial port and a minimal keyboard controller round out the device set. The virtio devices are built for virtual environments rather than to copy legacy physical hardware, so there is less complexity at this boundary.

An agent running malicious code cannot probe USB, graphics, or PCI emulation that Firecracker does not include. Firecracker is also written in Rust, whose memory-safety guarantees lower the risk of memory corruption in the device paths that the guest can reach. These choices address both the amount of exposed code and a class of faults within that code.

The host also restricts the VMM process itself. Firecracker’s external jailer builds a chroot, sets up resources that require elevated permissions, and drops privileges before starting the VMM. Firecracker then applies per-thread seccomp-bpf filters to limit its own host system calls. These restrictions add another containment layer if a device-handling bug is exploited. The guest kernel, virtualization boundary, and jailed VMM are separate barriers, each of which goes beyond policies that depend only on the kernel that runs the workload.

How container isolation actually works at the system-call and namespace level, and where it falls short for adversarial workloads

Container isolation changes what a process can see and do without giving it a separate kernel. A process namespace presents a private process tree, and a network namespace presents separate network interfaces and a network stack. A mount namespace defines the filesystem view. A user namespace can provide a separate UID/GID mapping. These are real restrictions, but every system call still enters the host kernel that enforces them.

Seccomp-bpf filters restrict callable system calls, while AppArmor or SELinux profiles limit permitted operations. Cgroups constrain resource use. Together, these mechanisms can harden a container substantially. Their strength still depends on correct policy and on the shared kernel safely handling the operations that remain available.

A permitted call is not automatically an escape path. An allowed operation may reach a kernel bug, or a policy may leave more authority available than intended. Because the same kernel runs and confines the process, a successful kernel compromise can undermine the controls around it. Rootless configurations and strong seccomp profiles reduce that exposure. They do not add a guest kernel or a hardware virtualization boundary.

For an agent, the trust assumption is different. An agent may browse the web, run shell commands, and run code that a model generates over several steps. Its inputs can push it to do things that a human developer did not write and review. The environment must therefore limit what the application can do when it turns hostile, as well as support its intended behavior. A shared-kernel policy boundary is a weaker fit for that threat model than a separate guest whose kernel privileges stop at the virtualization boundary.

Memory ownership in a Firecracker micro-VM versus a container process

Container processes depend on the host kernel to manage their virtual address spaces. The same kernel allocates ordinary processes’ pages and enforces their memory separation. Cgroups limit how much memory a container consumes. A successful host-kernel exploit can expose memory that belongs to other containers, even with the limits and namespace views that each has.

Firecracker gives guest memory a different boundary. The VMM allocates a region on the host and maps it into the guest’s physical address space. Extended page tables enforce that mapping, using EPT on Intel and NPT on AMD. Gaining privilege inside its own kernel does not let the guest address host memory outside its mapped region. The CPU enforces the guest’s memory boundary during memory access, rather than leaving that boundary to a policy the guest kernel can change.

The VMM still allocates the memory on a host machine, but the guest has authority only within the address space it is given. Another agent’s memory does not become accessible simply because the first agent controls its own kernel.

The separation has a real memory cost. Firecracker’s VMM overhead is approximately 5 MB per instance, plus user-configurable guest RAM, whose default is 128 MiB. A container process has almost no virtualization overhead of this kind. The per-VM cost accumulates at high density, but it is small enough to make a micro-VM per agent or user session practical. Guest RAM still belongs in that accounting, so the VMM figure alone does not describe the memory needed to run an agent.

There is also a firm limit on hardware access. Firecracker was designed without GPU passthrough, so an agent cannot use a host GPU for local model inference inside its micro-VM. This limits its fit for inference-heavy workloads. It does not affect an agent that calls a remote model and uses the sandbox only to execute code.

What a Firecracker snapshot actually preserves, and why that matters for stateful agent work

A Firecracker snapshot preserves more than the agent’s files or application variables. It captures guest RAM, including the guest kernel’s state, process memory, and in-flight data. It also saves the execution position and register values of each virtual CPU, along with the state of the virtual devices. Those pieces describe where the guest was when paused. Restoring them lets the guest continue from that execution point rather than starting a fresh process and reconstructing its work.

The guest kernel is part of that saved state. This follows directly from placing it inside the micro-VM boundary rather than sharing it with unrelated workloads on the host. Memory, CPU state, and virtual devices form a bounded execution context that can be serialized together. For a stateful agent, that provides a basis for sleeping and waking without discarding its running computation.

In a restore path using a memory service, Firecracker loads device state while the VM remains paused, then hands userfaultfd and the memory-region mappings to that service. The virtual CPUs resume only after the page-fault handler is ready. Firecracker’s snapshot documentation gives a baseline resume latency target of under 8 ms on Intel, with 5 ms p90, and under 3 ms on ARM.

Firecracker closes every guest vsock connection on resume, so a long-lived control channel breaks across the checkpoint-and-resume cycle. Applications must reconnect after each resume event.

Containers have checkpoint tools, but their scope differs. CRIU, which stands for Checkpoint/Restore In Userspace, can capture Linux process state within a shared kernel. It does not turn that process into a complete hardware-virtualized machine with its own saved kernel and address-space boundary. Its ability to preserve and restore state is therefore narrower than the micro-VM model. Process checkpointing also does not add the memory isolation needed to separate hostile tenants.

Why these architectural differences determine whether a runtime can safely hold persistent agent work

The agent may execute untrusted code, retain sensitive state, and need to resume after a pause while sharing a host with other agents. Firecracker’s design connects those needs. The guest kernel separates the agent’s system calls from the host kernel, the small device model limits guest-reachable VMM code, and hardware memory mappings confine the guest’s address space. Snapshotting then works on the execution context inside that boundary.

For untrusted execution, guest privilege is the decisive distinction. An agent that gains control of its guest kernel still has a virtualization boundary to cross before reaching the host. For sleep and wake, the useful distinction is ownership of the state being saved, including the kernel, memory, virtual CPUs, and devices. For multiple tenants, the requirement is to keep one compromised agent from exposing its neighbors. These properties reinforce one another, though none makes a hypervisor bug impossible or removes the need for host-side containment.

The practical limits remain part of the decision. A Firecracker agent needs guest RAM in addition to VMM overhead, cannot use GPU passthrough, and must reconnect vsock control channels after resume. Containers have no separate guest-kernel cost and are still faster and lighter for trusted work. They are a good fit for packaging, CI/CD, stateless API handlers, and code that a human wrote and reviewed.

For a long-running agent executing generated code, packaging alone is not enough. The runtime must constrain unexpected behavior while retaining the state needed to continue useful work. Firecracker does both through a separate kernel, limits on virtual hardware, hardware-enforced memory separation, and a guest execution context that can be restored. A container’s namespaces and resource limits do not provide an equivalent boundary.

More in Sandbox & Runtime