﻿---
title: Sandbox
description: By default the agent runs on your machine in a temporary workspace. To keep its files and network away from the machine, run it in a container: silk runs...
url: https://docs-v3-preview.elastic.dev/workflow/sandbox
---

# Sandbox
By default the agent runs on your machine in a temporary workspace. To keep its files and network away from the machine, run it in
a container:
```yaml
environment:
  sandbox:
    docker: {image: silk-claude-agent, env: [ANTHROPIC_API_KEY], network: none}
```

silk runs `docker run --rm --init`, mounts the workspace at the same path, and passes each variable in `env:` **by name only**
(the value never appears on a command line). On a timeout it runs `docker kill`. `env:` entries with `=` are refused.
- Works for Claude, Codex and Cursor. ACP agents (Copilot, Gemini, opencode) refuse a sandbox.
- **The image is yours.** It needs the agent CLI installed. Claude Code refuses `bypassPermissions` as root, so the image must run as
  a non-root user. Log in with an API key variable, not your host login (that lives in the keychain and is not copied in).
- A stdio MCP server given by a host path (`./server.sh`, `command: silk`) does not exist inside the image; use an image that has
  it, or an `http` server.


## What was verified

Run for real on OrbStack (Docker 29, linux/arm64): with a stand-in agent (mount, working directory, by-name secrets,
`network: none`, files the container wrote visible on the host, kill on timeout), and with the real Claude CLI 2.1.334 in a
`node:22-slim` image with `ANTHROPIC_API_KEY` passed by name (the skills example passed 2/2, no container left behind).
**Not verified:** Docker Desktop, Windows containers, Codex or Cursor inside an image. The sandbox limits where the agent's files
and network go; it is not presented as a hardened security boundary.