LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

sbx

Run AI coding agents in isolated sandboxes

TLDR

Open the interactive dashboard
$ sbx
copy
Sign in to Docker
$ sbx login
copy
Run an agent in the current directory
$ sbx run [claude]
copy
Run an agent on a named sandbox
$ sbx run --name [my-project] [claude] [path/to/project]
copy
List sandboxes
$ sbx ls
copy
Open a shell in a running sandbox
$ sbx exec [-it|--interactive --tty] [sandbox_name] [bash]
copy
Stop a sandbox without deleting it
$ sbx stop [sandbox_name]
copy
Remove a sandbox
$ sbx rm [sandbox_name]
copy
Allow a host through the network policy
$ sbx policy allow network [hostname]
copy
Store a service secret (prompted when the name is omitted)
$ sbx secret set [github]
copy

SYNOPSIS

sbx [--cloud] [-D] [command] [args...]

DESCRIPTION

sbx is the command-line interface for Docker Sandboxes. It creates isolated environments for AI coding agents such as Claude Code, Codex, and Gemini CLI. Each local sandbox is a microVM with its own kernel, filesystem, and private Docker daemon, so the agent can install packages and build containers without using the host Docker engine.With no command, sbx opens a terminal dashboard of sandbox cards (status, CPU, and memory). The same screen is sbx tui. From it you can create, start, stop, attach, shell into, and remove sandboxes, and edit network rules.sbx run creates a sandbox if needed and attaches to the agent. The first argument is a built-in agent name or a sandbox kit (a local directory, a zip, a git repository, or an OCI reference). Extra arguments after `--` are passed to the agent. Repeating sbx run on the same workspace reconnects to the existing sandbox. --name gives the sandbox a stable identity so you can reattach from another directory, or run several sandboxes against one tree.The host directory is mounted at the same absolute path inside the sandbox. That direct mode is the default: the agent can read and write the working tree, and edits show up on the host immediately. --clone instead checks out a private copy inside the sandbox. The host repository is then available read-only at `/run/sandbox/source`. Clone mode is fixed at creation time.--cloud sends supported commands to Docker Cloud Sandboxes instead of the local `sandboxd` daemon. Local and cloud sandboxes have separate credentials, network policy, and lifecycle. The CLI and local compute are free to use. Cloud compute is billed separately, and model-provider charges are separate from Docker.sbx does not require Docker Desktop or Docker Engine on the host.

PARAMETERS

--cloud

Dispatch to the Docker Cloud Sandboxes API instead of local `sandboxd`. Not every subcommand supports it. `sbx --cloud --help` lists the ones that do.
-D, --debug
Enable debug logging.
login
Sign in to Docker in a browser. Required before creating sandboxes.
logout
Stop running local sandboxes and sign out.
run [flags] [agent|kit] [path...]
Create a sandbox if it does not exist and attach to the agent. See RUN OPTIONS.
create [flags] agent|kit [path...]
Create a sandbox without attaching. A local sandbox stops when nothing is using it. Files and configuration remain until rm.
ls
List sandboxes, including status, agent, published ports, workspace, and age.
exec [-it] [flags] sandbox command
Run a command in a sandbox. The default working directory is the primary workspace. Detached exec is not supported.
stop sandbox...
Stop one or more sandboxes without deleting them.
rm [-f] sandbox...
Remove one or more sandboxes. Prompts for confirmation. --force skips the prompt and allows removal while a session, SSH connection, or SFTP transfer is active.
prune [--dry-run] [--filter until=DURATION]
Remove stopped local sandboxes. Running sandboxes are kept. --dry-run only prints the list.
attach sandbox
Attach to a cloud sandbox, starting it first if it is stopped.
cp src dest
Copy files between the host and one sandbox. One side must be `sandbox:absolute-path`. Copying between two sandboxes is not supported.
ports sandbox [--publish host:sandbox] [--unpublish spec]
Publish or remove a port forward. Publishing a port on a stopped local sandbox starts it. Give only the sandbox port to let the OS pick the host port.
policy command
Manage network and filesystem access rules: allow, deny, ls, rm, inspect, check, log, init, and reset.
secret command
Store, list, and import credentials. The host proxy injects them so they are not written into the sandbox filesystem.
template command
Save a sandbox filesystem as an image, list images, load a tar, or remove one. Mounted workspaces are not part of the saved image.
daemon command
Manage the local `sandboxd` daemon.
move
Move a sandbox between the local machine and Docker's cloud.
ttl
Show or extend a cloud sandbox's time to live.
mcp
Register MCP servers for sandboxed agents.
volume
Manage persistent volumes. Cloud only.
settings
Manage Docker Sandboxes settings.
diagnose
Check the local installation.
version
Print the version.
completion shell
Print a shell completion script.
tui
Open the interactive dashboard. This is also the default when no command is given.
reset
Remove sandboxes and local state. Prompts unless forced. Can keep stored secrets.
env
Experimental. Manage sandboxes from an `sbxenv.yaml` file.
kit
Experimental. Manage sandbox kit artifacts.
setup
Experimental. Detect host configuration and prepare Docker Sandboxes.
skills
Experimental. Manage skills available inside sandboxes.

CONFIGURATION

sbx policy init allow-all|balanced|deny-all

Choose the global network preset. `balanced` is the recommended starting point. Later changes use `sbx policy allow`, `sbx policy deny`, and `sbx policy rm`. Rules apply to every sandbox unless --sandbox name is set. `sbx policy reset` clears custom policy and asks for a preset again. Running sandboxes are stopped when the local daemon restarts.
sbx secret set
Store a credential for a supported service, a custom host, or a registry (`sbx secret set --registry`). Prefer this to writing tokens into the sandbox or into a saved template.
/etc/sandbox-persistent.sh
Inside a sandbox, Bash sources this file for later interactive sessions and for agents started with sbx run. Append `export` lines via `sbx exec` when a variable must outlive a single -e flag. A command passed straight to sbx exec does not start a shell.

RUN OPTIONS

--name name

Assign or reattach to a sandbox by name. The agent argument can be omitted when reattaching.
--rm
Delete the sandbox when the agent exits, without a prompt. The sbx run exit status is the agent's. Cannot be combined with --detach or --detach-keys.
-d, --detach
Start the sandbox and return without an agent session. The sandbox keeps running until stop or rm. Using this on an existing sandbox switches it to detached mode permanently.
--clone
Give the agent a private in-sandbox Git clone. Must be set when the sandbox is created. The primary workspace has to be the main checkout of a Git repository, not a linked worktree.
-t, --template image
Create the sandbox from a template image. Pass the full reference. sbx does not assume `docker.io`.
--publish host:sandbox
Publish a port at creation time. Ignored when run reattaches to an existing sandbox. Use sbx ports for that case.
-e, --env var[=value]
Set an environment variable in the sandbox. A bare name copies the value from the host. On create, the variable is stored with the sandbox. On reattach, it applies to that session only. Requires sbx 0.39.0 or later.
--env-file path
Load variables from a file. Later files override earlier ones. -e overrides both.
--cpus n
CPUs to assign. `0` means all host CPUs, at most 16 on Linux arm64.
--deny-network host
Add a per-sandbox network deny rule at creation. Repeat for more hosts. A local deny can only narrow access.
--allow-network pattern
Network pattern to allow for cloud sandbox egress. Cloud only. Repeatable.

INSTALL

nix profile install nixpkgs#docker-sbx
copy

CAVEATS

This page is Docker's sbx command. It is unrelated to the Python package `sbx-rl` (Stable Baselines Jax), which is imported as a library and is not this binary.Local sandboxes need a hypervisor. On Linux that is KVM, and the user must be in the `kvm` group. Docker supports local sandboxes on Ubuntu 24.04 or later (x86_64 or arm64). Nested virtualization is required when the host itself is a VM. macOS needs Apple silicon and macOS Sonoma or later. Windows needs Windows 11 and Windows Hypervisor Platform. --cloud does not need KVM.`sbx rm` deletes the sandbox filesystem, including packages installed inside it and a clone-mode worktree. Host workspace files and the shared skills store on the host stay. A saved template includes files from the container filesystem, so credentials written into the sandbox are baked into the image.Network access is denied or limited by policy. A process inside the sandbox is not reachable from the host until a port is published.Sign-in is required. `sbx login` uses a browser OAuth flow.nixpkgs ships this command as `docker-sbx` and marks the package unfree.

SEE ALSO

docker(1)

RESOURCES

Copied to clipboard
Kai