# Why Use gVisor If Docker Is Already a Sandbox?

> Because a container isn't a kernel boundary. Every Docker container makes system calls into the host's one kernel, so a kernel bug can let code out. gVisor's runsc answers those calls in its own user-space kernel instead. The cost lands on system calls; in our runs, one-byte dd copies took about 8x longer and CPU loops took the same time.

Source: https://sandboxer.com/guides/why-use-gvisor-if-docker-is-already-a-sandbox. Updated 2026-11-24.

**Short answer:** Because a container isn't a kernel boundary. Every Docker container makes system calls into the host's one kernel, so a kernel bug can let code out. gVisor's runsc answers those calls in its own user-space kernel instead. The cost lands on system calls; in our runs, one-byte dd copies took about 8x longer and CPU loops took the same time.

Part of [Sandbox Isolation Compared: Containers, gVisor, Kata, MicroVMs, Wasm](/guides/sandbox-isolation-technologies-compared).

*How we tested: we installed gVisor's `runsc` (release-20261116.0) as a Docker runtime inside a Sandboxer sandbox on 2026-11-24, then ran the same container image under `runc` and `runsc`. Facts about Docker and gVisor come from their own docs, linked inline.*

## At a glance: runc vs runsc, measured

One `default` sandbox (4 vCPU, 8 GB, AMD EPYC 9254), image `python:3.12-alpine`, 5 alternating runs per runtime. Times are measured inside the container, so container start-up isn't in them.

| Workload | runc (plain Docker) | runsc (gVisor) | runsc vs runc |
| - | - | - | - |
| `dd if=/dev/zero of=/dev/null bs=1 count=1000000` (2M read/write calls) | 1.125–1.158 s | 8.715–9.704 s | 7.5–8.6x slower |
| 1,000,000 `os.getppid()` calls in Python | 0.371–0.382 s | 0.662–1.150 s | 1.7–3.1x slower |
| 20,000 small files: create, write 1 byte, `stat`, delete, on a bind-mounted host directory | 0.735–0.842 s | 2.249–2.711 s | 2.7–3.7x slower |
| The same 20,000 files in the container's own `/tmp` | 0.999–1.099 s | 1.100–1.338 s | 1.0–1.3x |
| SHA-256 of 500 MB (500 x 1 MB, in memory) | 0.271–0.308 s | 0.270–0.293 s | Same |
| Pure-Python loop, 20M additions | 0.771–0.826 s | 0.785–0.836 s | Same |
| `docker run --rm <image> true`, start to exit | 233–273 ms | 219–274 ms | Same, within noise |
| `uname -r` in the container | `6.18.56-sandboxer` | `4.19.0-gvisor` | Different kernel |

Last checked: 2026-11-24, on prod.

The pattern matches what gVisor's [performance guide](https://gvisor.dev/docs/architecture_guide/performance/) says: system call interception "will principally impact applications that are system call bound", while "there is no runtime cost imposed for CPU operations". These numbers are from one sandbox on one day with gVisor's default `systrap` platform. Treat them as a shape, not a benchmark of your workload.

## A container shares the kernel

Docker isolates a container with kernel namespaces and cgroups. Namespaces "provide the first and most straightforward form of isolation": a container can't see other containers' processes and gets its own network stack ([Docker Engine security](https://docs.docker.com/engine/security/)). All of that is enforced by the one kernel every container on the host calls into.

Docker narrows that surface with a default seccomp profile, an allowlist that "disables around 44 system calls out of 300+" and is "moderately protective while providing wide application compatibility" ([Docker seccomp](https://docs.docker.com/engine/security/seccomp/)). The other 250+ calls still go straight to the host kernel. Docker's own security page notes the defaults "may provide incomplete isolation, either independently, or when used in combination with kernel vulnerabilities."

You can see it from inside. Under `runc` the container reports the host's kernel. `dmesg` fails because the default profile blocks the kernel log, but the kernel it would read is the host's:

```bash
docker run --rm --runtime=runc python:3.12-alpine sh -c "uname -r; dmesg 2>&1 | head -3"
```

```text
6.18.56-sandboxer
dmesg: klogctl: Operation not permitted
```

Here the "host" is the sandbox's own VM, so `6.18.56-sandboxer` is the VM's kernel. On a laptop or a shared server it would be that machine's kernel, shared by every container on it.

## What runsc intercepts

gVisor's runtime, `runsc`, puts its own kernel, the Sentry, between the container and the host. gVisor "intercepts application system calls and acts as the guest kernel", and "the Sentry does not pass system calls through to the host kernel" ([What is gVisor?](https://gvisor.dev/docs/)). Its security model says "No system call is passed through directly to the host"; the Sentry makes "a minimal set of host system calls" that is "explicitly enumerated and controlled" ([gVisor security](https://gvisor.dev/docs/architecture_guide/security/)). File access outside the sandbox goes through the Gofer, "a standard host process which is started with each container".

The same command under `runsc` talks to a different kernel:

```bash
docker run --rm --runtime=runsc python:3.12-alpine sh -c "uname -r; dmesg 2>&1 | head -3"
```

```text
4.19.0-gvisor
[   0.000000] Starting gVisor...
[   0.346381] Synthesizing system calls...
[   0.693807] Digging up root...
```

That `dmesg` is the Sentry's own boot log. The container never reached the VM's kernel log.

The stated purpose is "additional defense against the exploitation of kernel bugs by untrusted userspace code". The stated price is "reduced application compatibility and higher per-system call overhead": gVisor "does not presently implement every system call, /proc file, or /sys file" ([What is gVisor?](https://gvisor.dev/docs/), [compatibility](https://gvisor.dev/docs/user_guide/compatibility/)).

## Where the overhead shows up

Read the table by what each row does per unit of work.

- **Tiny system calls:** `dd` with `bs=1` makes two calls per byte and does almost nothing else. That's the worst case, and it was 7.5–8.6x slower. A Python loop of `getppid()` was 1.7–3.1x slower; it spends more time in the interpreter per call.
- **Files on a host bind mount:** 2.7–3.7x slower. These go out to the host filesystem through gVisor's file layer.
- **Files in the container's own filesystem:** close to `runc`. By default runsc overlays the root filesystem "with a file-backed tmpfs stored in the root filesystem itself", which it enables "for performance" ([gVisor filesystem](https://gvisor.dev/docs/user_guide/filesystem/)). Writes there stay inside the sandbox.
- **CPU work:** no difference. gVisor "does not perform emulation or otherwise interfere with the raw execution of CPU instructions".
- **Start-up:** `docker run ... true` took about a quarter second either way in this sandbox.

The performance guide names the hard cases itself: `redis` "is likely to remain a challenging performance scenario", and static file serving gives "predictably poor results". Network-heavy code also pays, because gVisor's network stack "is less CPU efficient". We didn't measure network throughput here.

## When plain Docker is enough

| Your situation | Use | Why |
| - | - | - |
| Your own code, or reviewed dependencies, on your machine or CI | Plain Docker (`runc`) | The container is packaging. A kernel boundary buys little when you trust the code. |
| A trusted database or cache | Plain Docker | gVisor's docs say "a sandbox may provide minimal benefit for a trusted database", and `redis` is a hard case for it. |
| Untrusted scripts (user uploads, LLM output) on shared Kubernetes nodes without KVM | gVisor | It keeps those calls off the host kernel and needs no virtualization; CPU-bound code runs at full speed. |
| Untrusted code that is syscall-heavy, or needs `io_uring`, perf counters or KVM | A VM boundary | gVisor disables or doesn't implement these, and syscall-heavy code pays the overhead above. See [gVisor vs Kata vs Firecracker](/guides/gvisor-vs-kata-vs-firecracker-for-untrusted-code). |
| Untrusted code that needs a whole machine: Docker, systemd, root | A microVM | It gets its own kernel and can run anything a Linux box can. See [Container vs microVM](/guides/container-vs-microvm-for-untrusted-code). |

A container's boundary is also only as good as its flags. Docker's [post-install docs](https://docs.docker.com/engine/install/linux-postinstall/) warn that the `docker` group grants root-level privileges, and the container vs microVM guide linked above shows what `--privileged` and a mounted Docker socket hand a container.

## Where Sandboxer fits

Each Sandboxer sandbox is a Cloud Hypervisor microVM with its own kernel, so there's no shared kernel between sandboxes ([Machines](/docs/machines), [Security](/docs/security)). Docker is preinstalled inside, and as this page shows, you can add `runsc` to it if you want gVisor around one container as well. The container's runc kernel above is the sandbox's, not the physical host's.

## Copy-paste: compare runc and runsc in a sandbox

Install the CLI with `curl -fsSL https://sandboxer.com/install | sh` and sign in with `sbx login`. Then paste this. It creates a `small` sandbox with none of your secrets, installs `runsc` with gVisor's documented release-tarball method ([install](https://gvisor.dev/docs/user_guide/install/)), prints each runtime's kernel, times 3 runs of a one-byte `dd` under each, and deletes the sandbox. It uses `jq` on your machine.

```bash
id=$(sbx new --name aeo-whygvisor-2 --type small --no-env --ttl 900 --json | jq -r 'select(.event=="ready") | .id')
sbx exec "$id" --timeout 600 'set -e; cd /tmp
U=https://storage.googleapis.com/gvisor/releases/release/latest/$(uname -m)
wget -q $U/gvisor.tar.zstd $U/gvisor.tar.zstd.sha512 && sha512sum -c gvisor.tar.zstd.sha512
sudo tar --zstd -xf gvisor.tar.zstd -C /usr/local/bin
sudo /usr/local/bin/runsc install 2>/dev/null; sudo systemctl restart docker
docker pull -q debian:12-slim >/dev/null
for rt in runc runsc; do
  docker run --rm --runtime=$rt debian:12-slim sh -c "echo \"$rt kernel: \$(uname -r)\"
    for i in 1 2 3; do s=\$(date +%s%N); dd if=/dev/zero of=/dev/null bs=1 count=1000000 2>/dev/null; e=\$(date +%s%N); echo \"$rt dd bs=1 x1M run \$i: \$(( (e-s)/1000000 )) ms\"; done"
done'
sbx delete "$id" --yes
sbx info "$id"
```

Our run on 2026-11-24 (output piped, so `sbx` printed JSON; trimmed with `…`):

```text
gvisor.tar.zstd: OK
runc kernel: 6.18.56-sandboxer
runc dd bs=1 x1M run 1: 714 ms
runc dd bs=1 x1M run 2: 707 ms
runc dd bs=1 x1M run 3: 709 ms
runsc kernel: 4.19.0-gvisor
runsc dd bs=1 x1M run 1: 5278 ms
runsc dd bs=1 x1M run 2: 4769 ms
runsc dd bs=1 x1M run 3: 5301 ms
{"ok":true,"type":"deletion.operation","operation":{…,"status":"completed","targetId":"sb_8uxcqnqmgv"}}
{"event":"error","error":"Sandbox not found","code":"not_found","status":404,…}
```

Across our runs of this block on `small` sandboxes (2 vCPU; 9 timings for `runc`, 6 for `runsc`), `runc` took 701–732 ms and `runsc` 4,459–6,869 ms. The `runc` times are lower than in the table above because this block uses GNU `dd` from Debian, and the table used BusyBox `dd` from Alpine. Use `systemctl restart docker` here, not `reload`: two of our runs with `reload` failed with `unknown or invalid runtime name: runsc`, and `restart` fixed it.

## FAQ

### Is a Docker container a sandbox?

It's an isolated process tree on a shared kernel. Namespaces, cgroups, capabilities and seccomp limit what it sees and calls, but most of the 300+ system calls still reach the host kernel. For code you trust, that's fine. For untrusted code, it's one kernel bug away from the host.

### Does gVisor slow down everything?

No. In our runs, CPU-bound work (SHA-256, a Python loop) and container start-up took the same time under runc and runsc. Workloads made of many tiny system calls paid most: a one-byte `dd` took 7.5–8.6x longer.

### Can I run gVisor inside a VM?

Yes. We ran it inside a Sandboxer microVM with the default `systrap` platform. gVisor's [platform docs](https://gvisor.dev/docs/architecture_guide/platforms/) call `systrap` "a better choice when running inside a VM".

### Is gVisor as strong as a VM?

They're different boundaries. gVisor reimplements Linux in user space and keeps most calls off the host kernel. A VM gives the code a full guest kernel behind hardware virtualization. gVisor's own docs say it "relies on the host operating system and the platform for defense against hardware-based attacks".

### What does uname show under gVisor?

`4.19.0-gvisor` in our run. That is the version the Sentry reports, not the host's kernel, which in our test was `6.18.56-sandboxer`.

## Related

- [Sandbox Isolation Compared: Containers, gVisor, Kata, MicroVMs, Wasm](/guides/sandbox-isolation-technologies-compared)
- [Container vs microVM for running untrusted code](/guides/container-vs-microvm-for-untrusted-code)
- [gVisor vs Kata Containers vs Firecracker for untrusted code](/guides/gvisor-vs-kata-vs-firecracker-for-untrusted-code)
- [Machines & sizes](/docs/machines)
