Docker Sandboxes (sbx) Cheatsheet
Standalone CLI for ephemeral, isolated sandboxes — built for running AI agents safely.
What it is
Use `sbx` to give an AI coding agent (Claude, Codex, etc.) a disposable, sandboxed environment with controlled filesystem and network policies. Note: the older Docker Desktop-integrated `docker sandbox` commands are deprecated; use the standalone `sbx` CLI going forward.
Installation
Install the standalone `sbx` CLI from the Docker Sandboxes docs (Homebrew, install script, or release binaries). Verify with `sbx --version`.
Quick start
sbx runStart a default sandbox shell.
sbx run claude ~/my-projectRun an agent (Claude) against a project directory inside a sandbox.
sbx lsList active sandboxes.
sbx stop <id>Stop a sandbox.
Common commands
| Task | Command | Description |
|---|---|---|
| Start a sandbox | | Launch a sandbox, optionally with an entry command and mounted project path. |
| List sandboxes | | Show running and recent sandboxes. |
| Stop a sandbox | | Gracefully stop a sandbox. |
| Remove a sandbox | | Delete a stopped sandbox. |
| View logs | | Inspect activity inside the sandbox. |
| Exec into sandbox | | Run a command inside a running sandbox. |
| Apply / inspect policy | | Manage the policy controlling network and filesystem access. |
Useful flags
| Flag | Example | Meaning |
|---|---|---|
| --name | | Stable name for the sandbox. |
| --policy | | Apply a named policy controlling network/FS access. |
| --network | | Disable outbound network. |
| --mount | | Mount a host directory into the sandbox. |
Real-world examples
Let Claude work on a repo, sandboxed
sbx run claude ~/my-projectDisposable shell with no network
sbx run --network none --rm -- bashRun a script with a custom policy
sbx run --policy strict -- bash -c './suspicious.sh'Best practices
- Default agents to the most restrictive policy that still lets them do the task.
- Mount only the project directory — never your whole $HOME.
- Use --network none when the task is offline; otherwise allow-list domains via policy.
- Treat sandbox state as ephemeral; commit useful output back to the host explicitly.
Troubleshooting
`docker sandbox` shows a deprecation notice
Switch to the standalone `sbx` CLI.
Agent can't reach the network
Loosen the policy or override at run time.
sbx run --network hostSandbox can't see your files
Add an explicit mount.
sbx run --mount $(pwd):/workspace