---
source: https://iinventedlight.com/library/notes/ao-sandbox-inspect-docker-tools.md
title: "Running eval tool calls in a sandbox: Inspect sandbox() with Docker or gVisor"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (UKGovernmentBEIS/inspect_ai (GitHub)); Apache-2.0 (google/gvisor (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: UKGovernmentBEIS/inspect_ai (GitHub), Sandboxing (Inspect docs), MIT (https://raw.githubusercontent.com/UKGovernmentBEIS/inspect_ai/main/LICENSE). Copyright (c) 2024 UK AI Security Institute; google/gvisor (GitHub), gVisor Docker quick start, Apache-2.0 (https://raw.githubusercontent.com/google/gvisor/master/LICENSE)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-17
as_of: 2026-11-17
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: sandboxing"
tags: [sandbox, inspect-ai, docker, evals, gvisor]
client: Librarian
sources:
  - id: S1
    title: "Sandboxing (Inspect docs)"
    publisher: UKGovernmentBEIS/inspect_ai (GitHub)
    url: https://github.com/UKGovernmentBEIS/inspect_ai/blob/main/docs/sandboxing.qmd
    accessed: 2026-11-16
    license: "MIT"
  - id: S2
    title: "gVisor Docker quick start"
    publisher: google/gvisor (GitHub)
    url: https://github.com/gvisor/gvisor/blob/master/g3doc/user_guide/quick_start/docker.md
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# Running eval tool calls in a sandbox: Inspect sandbox() with Docker or gVisor
**Answer:** In Inspect, model tool calls are executed within the main process, but the work tools perform, such as running shell commands, very often needs a dedicated, isolated environment. Add `sandbox="docker"` to a task and tools call `sandbox()` to reach the `SandboxEnvironment` for the current sample.

## Details

- A tool runs commands with `await sandbox().exec([...])` and checks `result.success`, `result.stdout` and `result.stderr`.
- Support for Docker sandboxes is built in; an Extension API enables the creation of additional sandbox types.
- Docker sandboxes accept standard `Dockerfile` and `compose.yaml` configuration.
- Compose's default network has outbound Internet access, so include `network_mode: none` unless the evaluation requires networking.

## Stronger isolation

gVisor provides a Docker runtime: after `sudo runsc install` and a daemon restart, containers run with `docker run --runtime=runsc`.

## See also

- [ao-sandbox-firecracker-and-gvisor](https://iinventedlight.com/library/notes/ao-sandbox-firecracker-and-gvisor/)
- [ao-evals-inspect-scorers](https://iinventedlight.com/library/notes/ao-evals-inspect-scorers/)
- [ao-evals-cli-lm-eval-and-inspect](https://iinventedlight.com/library/notes/ao-evals-cli-lm-eval-and-inspect/)
- [ao-security-e2b-cloud-sandboxes](https://iinventedlight.com/library/notes/ao-security-e2b-cloud-sandboxes/)

## Claims

- id: C1
  claim: Tool work needs an isolated environment.
  source: S1
  evidence: "very often needs to happen in a dedicated, isolated environment"

- id: C2
  claim: Docker sandboxes are built in.
  source: S1
  evidence: "Support for Docker sandboxes is built in"

- id: C3
  claim: Use network_mode none by default.
  source: S1
  evidence: "include `network_mode: none` in your own configuration"

- id: C4
  claim: runsc runs containers under gVisor.
  source: S2
  evidence: "docker run --runtime=runsc --rm hello-world"

## Sources

- [S1] Sandboxing (Inspect docs). UKGovernmentBEIS/inspect_ai (GitHub). https://github.com/UKGovernmentBEIS/inspect_ai/blob/main/docs/sandboxing.qmd . License: MIT. Accessed 2026-11-16.

- [S2] gVisor Docker quick start. google/gvisor (GitHub). https://github.com/gvisor/gvisor/blob/master/g3doc/user_guide/quick_start/docker.md . License: Apache-2.0. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: UKGovernmentBEIS/inspect_ai (GitHub), Sandboxing (Inspect docs), MIT (https://raw.githubusercontent.com/UKGovernmentBEIS/inspect_ai/main/LICENSE). Copyright (c) 2024 UK AI Security Institute; google/gvisor (GitHub), gVisor Docker quick start, Apache-2.0 (https://raw.githubusercontent.com/google/gvisor/master/LICENSE). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
