gVisor explained: how the user-space kernel works, and when to use it for AI agents
What gVisor is, how its Sentry, Gofer and runsc runtime sandbox a container, how it compares with runc and microVMs, how to run it with Docker and Kubernetes, and where it fits for agents that run untrusted code.
By Designing AI Agents Editors · Updated
gVisor is an open-source application kernel for containers. Instead of letting a container's processes call the host's Linux kernel directly, gVisor puts its own kernel, written in Go and running in user space, between them. The application still sees a Linux-like system and runs unmodified in most cases, but the host kernel only ever hears from gVisor, through a small and filtered set of calls.
It was created by Google, which uses it to isolate workloads in GKE Sandbox, Cloud Run and App Engine, and it is now a Cloud Native Computing Foundation sandbox project. The project's own list of users includes several teams running AI-generated code, among them Anthropic for code execution in claude.ai and OpenAI for some higher-risk tasks such as code execution. This guide explains how gVisor works, how it compares with plain containers and microVMs, and what to check before you use it to sandbox agents. For the wider choice of sandbox, see the AI agent sandbox guide.
How gVisor works
A gVisor sandbox is a small group of host processes, started by gVisor's OCI runtime, runsc, in place of the usual runc. Three parts matter:
- The Sentry. gVisor's kernel. It implements system calls, signal delivery, memory management and page faults, and the threading model for the application. When the application makes a system call, the Sentry answers it; it does not pass the call through to the host. The Sentry itself runs under a restrictive seccomp filter and cannot open host files on its own.
- The Gofer. A separate host process, one per container, that mediates file system access. The Sentry asks the Gofer for files over a socket or shared-memory channel, so the process handling untrusted system calls is not the one holding the host file system.
- The platform. The mechanism that intercepts the application's system calls and hands them to the Sentry. systrap, built on seccomp, has been the default since mid-2023 and works inside ordinary cloud VMs. KVM uses hardware virtualization extensions and performs best on bare metal. The older ptrace platform is no longer supported.
Networking works the same way. gVisor ships its own TCP/IP stack, netstack, inside the Sentry, so connection state and packet handling stay out of the host's network stack. You can switch to the host's stack (--network=host) for throughput at the cost of isolation, or turn external networking off entirely (--network=none).
The gVisor documentation describes the design as "a merged guest kernel and VMM, or seccomp on steroids": it is not a syscall filter and not a virtual machine in the everyday sense, but a third approach between them.
gVisor vs runc containers vs microVMs
Most people looking at gVisor are choosing between three ways to run a container image: the default runc runtime, gVisor's runsc, or a microVM such as Firecracker or Kata Containers.
| runc (default containers) | gVisor (runsc) | MicroVM (Firecracker, Kata, Cloud Hypervisor) | |
|---|---|---|---|
| Who answers system calls | The host kernel, directly | gVisor's Sentry, in user space | A guest Linux kernel inside the VM |
| Isolation boundary | Namespaces, cgroups, seccomp | A separate application kernel, itself sandboxed with seccomp and namespaces | Hardware virtualization (KVM) |
| Needs KVM on the host? | No | No with systrap; optional with the KVM platform | Yes; bare metal or nested virtualization |
| Resource model | Ordinary processes | Ordinary processes and memory mappings; no fixed guest memory | A VM with its own allocated memory and vCPUs |
| Linux compatibility | Full; it is the host kernel | Most applications; not every system call, /proc or /sys file is implemented | Full guest Linux |
| Main cost | Weakest boundary between tenants | Overhead on system-call-heavy and I/O-heavy work | Running VMs: KVM hosts, guest images, VM lifecycle |
| Works with | Docker, containerd, Kubernetes | Docker, containerd, CRI-O, Kubernetes (RuntimeClass) | Kata on Kubernetes; Firecracker through its own API or tooling |
The practical difference from a microVM is that gVisor keeps the container's process model. It does not need hardware virtualization, so it runs on ordinary cloud instances without nested virtualization, and it does not reserve a fixed block of memory per sandbox. The price is compatibility and per-call overhead: software that leans on unusual system calls or does heavy file and network I/O can run slower or hit unimplemented features. MicroVMs explained covers the other side of the comparison.
Neither boundary is the same as a separate kernel per tenant on hardware virtualization. Why every AI agent needs its own kernel argues the case for microVMs, and tenant-scoped execution boundaries weighs where a user-space kernel is enough.
Running gVisor with Docker and Kubernetes
gVisor runs on Linux hosts (x86_64 and ARM64) and its install guide requires Linux 5.6 or later. Because runsc is an OCI runtime, adopting it is mostly configuration:
- Docker. Install the runsc package from gVisor's apt repository (which configures Docker for you) or the release tarball, run sudo runsc install to add a runtime named runsc to /etc/docker/daemon.json, restart Docker, then start containers with docker run --runtime=runsc.
- Kubernetes with containerd. Install the containerd-shim-runsc-v1 shim on each node, register it in containerd's config, create a RuntimeClass for it, and set runtimeClassName on the pods that should be sandboxed. CRI-O is also supported.
- GKE Sandbox. On Google Kubernetes Engine, create a node pool with GKE Sandbox enabled and pods with runtimeClassName: gvisor run inside gVisor without installing anything yourself.
- Directly. runsc can run an OCI bundle on its own, and gVisor publishes experimental Go and Python SDKs for creating sandboxes and running commands in them. The project marks the SDKs as not meant for production use yet.
Read gVisor's production guide before you put it in front of real users; it covers platform choice, networking and file system options that change both performance and isolation.
When gVisor fits an AI agent
Agents run code nobody reviewed: commands the model wrote, packages it chose, files it downloaded. gVisor is a common choice for containing that code, and it fits best when:
- You already run containers on Kubernetes. Switching a pod's runtime class is far less work than standing up a microVM fleet, and your images, scheduling and tooling stay the same.
- Your hosts can't run KVM. On cloud instances without nested virtualization, systrap still works, while a microVM would not start.
- Sandboxes are short-lived and plentiful. Code-interpreter calls, tool runs and evals that start, do one job and exit suit gVisor's process-like footprint.
- The agent needs a GPU. gVisor's nvproxy runs most CUDA applications on supported NVIDIA drivers, with the --nvproxy flag. Check the GPU support page for the drivers and devices covered.
- You need to pause and resume. runsc checkpoint saves a running sandbox's state, memory included, to disk and runsc restore brings it back in a new container. This is the building block for agents that sleep when idle and wake with their state; see agent state persistence across sleep and redeploys. The docs list limits, for example around networking, clocks and moving a checkpoint between machines with different CPU features.
A microVM is the safer fit when policy requires a hardware-enforced boundary between tenants, when the agent's workload hits gVisor's compatibility gaps (test it: run your heaviest real task under runsc), or when each user's agent is a long-lived machine with its own kernel, packages and background services. Many teams use both: a persistent VM per user and gVisor sandboxes for the riskiest steps inside or beside it. The persistent VM pattern describes where per-user platforms tend to end up.
Whatever the runtime, the sandbox is only one boundary. Egress rules per tenant and keeping real credentials out of the sandbox matter as much; see credential and secret isolation in per-user agent VMs.
Common questions
Is gVisor a virtual machine?
Not in the usual sense. It does not emulate hardware or boot a guest Linux kernel. It is a user-space kernel that answers the application's system calls itself. With the KVM platform it uses virtualization extensions to speed up and harden address-space switching, but the sandbox still behaves like a set of processes.
Is gVisor more secure than Docker?
gVisor is a runtime you use with Docker, not a replacement for it. Compared with Docker's default runc runtime, it adds a boundary: a container escape has to get through gVisor's own kernel, which is sandboxed itself, before it reaches the host kernel. It does not remove the need for network rules, resource limits and up-to-date hosts.
gVisor or Firecracker for AI agent sandboxes?
gVisor if you want to stay in a container and Kubernetes workflow, can't rely on KVM, and your workloads run well under it. Firecracker or another microVM if you need a full guest kernel per tenant, full Linux compatibility, or a hardware-virtualization boundary. Test your real agent tasks on both before deciding. The AI agent sandbox guide has a checklist for the comparison.
Does gVisor slow applications down?
It can. gVisor's performance guide describes extra cost on system calls, file system and network I/O, while compute-bound code runs close to native. The overhead depends on the platform, the workload and the configuration, so benchmark your own workload rather than relying on published numbers.
Does gVisor run on macOS or Windows?
No. gVisor runs on Linux hosts only. On a Mac or Windows machine you would run it inside a Linux VM. Docker Desktop for Mac uses gVisor's network stack library, but not gVisor as a container runtime.
Who uses gVisor?
Google built it for its own services and uses it in GKE Sandbox, Cloud Run and App Engine. gVisor's public users page also lists, among others, Anthropic, OpenAI, Cloudflare, DigitalOcean, Modal and Snowflake, each in its own words.



