Join our Discord Server

Docker Sandboxes (sbx) Cheatsheet

← All cheatsheets
AiIntermediate

Docker Sandboxes (sbx) Cheatsheet

Standalone CLI for ephemeral, isolated sandboxes — built for running AI agents securely.


What it is

Docker sbx creates lightweight, ephemeral container sandboxes that give AI agents a safe, isolated environment to execute code, run commands, and explore data without affecting the host.

Installation

Install with docker sbx install or as part of Docker Desktop. Run docker sbx version to verify.

Quick start

docker sbx create

Create a new ephemeral sandbox.

docker sbx run my-sandbox -- python3 script.py

Execute a command inside a sandbox.

docker sbx list

Show all active sandboxes.

docker sbx rm my-sandbox

Destroy a sandbox.

Common commands

TaskCommandDescription
Create sandboxdocker sbx createAllocate a new isolated sandbox container.
Run commanddocker sbx run <id> -- <cmd>Execute a command inside the sandbox.
List sandboxesdocker sbx listShow all active sandboxes.
Inspect sandboxdocker sbx inspect <id>Show sandbox metadata and status.
Remove sandboxdocker sbx rm <id>Destroy and clean up a sandbox.
Copy files indocker sbx cp <src> <id>:<dest>Copy files into a sandbox.

Real-world examples

Create a sandbox and run Python
ID=$(docker sbx create)
docker sbx run $ID -- python3 -c "print(42)"
Give an AI agent a sandbox to work in
# Create sandbox
ID=$(docker sbx create)

# Let agent execute code
docker sbx run $ID -- bash -c "pip install pandas && python3 analyze.py"

# Clean up
docker sbx rm $ID

Best practices

  • Always destroy sandboxes after use — they are ephemeral by design.
  • Use sbx to give AI agents code execution abilities without host access.
  • Mount only the minimum files needed into a sandbox.

Related cheatsheets


Last reviewed: 2026-06-15
Join our Discord Server