2.1

sbx run, sbx create, sbx stop, and sbx rm

sbx run creates a sandbox when none exists and attaches to it, sbx create only creates, and stop, rm, and prune end a sandbox in three different ways.

You have a repository with two commits and a README, and you want a shell agent to work on it and on nothing else. The capture does that with sbx create shell $CAPTURE/fixtures/repo --name m101-demo, where $CAPTURE stands for the capture directory, and the rest of this part reuses that sandbox. When you finish this section, you can name the verb that creates, attaches, stops, removes, or prunes a sandbox, and what each one keeps.

The agent and the workspace

Agent: the first positional argument of sbx run and sbx create: either a built-in agent name or a reference to a sandbox kit. The built-in names are claude, codex, copilot, cursor, devin, docker-agent, droid, gemini, kiro, opencode, and shell. A kit reference is a directory, a ZIP file, a git repository, or an OCI reference. A relative path must be explicit, such as ./my-kit or ../my-kit.zip. So sbx run my-kit looks for an agent called my-kit, and sbx run ./my-kit reads a kit, as the kit descriptor explains.

Workspace: the directory after the agent, mounted inside the microVM at the same absolute path. Inside m101-demo, pwd prints $CAPTURE/fixtures/repo, and mount lists that path as a virtiofs mount. sbx run mounts the current directory when you give no path. sbx create without a path makes a sandbox with no mount.

There the agent works in the filesystem of the container instead of on your files. Extra paths follow the first one, and :ro mounts one of them read-only. A read-only argument can name a single file. That keeps one path out of reach in a workspace that the sandbox can otherwise write.

the create command and its summarytextFull log
$ sbx create shell $CAPTURE/fixtures/repo --name m101-demo

sandbox    m101-demo
agent      shell
workspace  $CAPTURE/fixtures/repo (rw)
image      docker/sandbox-templates:shell-docker
cpu        10
memory     32 GiB

Pulling image
  <layers>
✓ Image ready
✓ Created sandbox m101-demo

To connect to this sandbox, run:
  sbx run --name m101-demo
[exit 0]
Nothing is cut. The image layers are masked as <layers>.
the workspace seen from insidetextFull log
$ sbx exec m101-demo sh -c 'pwd; echo; ls -la; echo; cat README.md; echo; git log --oneline'
$CAPTURE/fixtures/repo
…
c7dfd56 second
086df68 first
[exit 0]
The directory listing and the README text are cut.

Names and re-attach

Name: the key of a sandbox in every later command, by default <agent>-<workdir>, the agent name and the workspace directory name. A name has at least two characters and starts with a letter or a number. It contains only letters, numbers, hyphens, and periods, and --cloud rejects periods. The name default is reserved. Since v0.43.0 the daemon also rejects a name that is longer than 63 characters or that ends in a hyphen or a period. The 2025 plugin allowed _ and + in a name, and conflict C25 records the change.

Two sandboxes can share one workspace. The capture creates m101-demo-2 on the same fixtures/repo, and sbx ls --json lists both as running. A blog post of 2026-03-11 said that Docker enforces one sandbox per workspace. A talk of 2026-08-13 runs claude and codex on one workspace in two terminals, and S27 rules that the names decide.

--name on sbx run re-attaches to an existing sandbox, and then you can leave out the agent. sbx run reads it from the spec of the existing sandbox. Give the agent too, and sbx run checks it against the stored one. sbx create prints that re-attach command at the end of its output.

two sandboxes on one workspacejsonFull log
{
  "sandboxes": [
    {
      "name": "m101-demo",
      …
      "status": "running",
      …
      "workspaces": [
        "$CAPTURE/fixtures/repo"
      ],
      …
    },
    {
      "name": "m101-demo-2",
      …
      "status": "running",
      …
      "workspaces": [
        "$CAPTURE/fixtures/repo"
      ],
      …
    }
  ]
}
Cut to the name, status, and workspace of each record. The ports of m101-demo belong to the next section.

What is fixed at creation

Some flags act on every attach, and most act once, when the sandbox is created. A re-attach with a different -p or --skills changes nothing, and the help says so flag by flag.

FlagWhen it appliesHelp page
-e KEY=VALUE, --env-file FILEthe agent session on every attach, and stored in the sandbox when this run creates itsbx run
--cpus N, -m SIZEat creation, memory defaults to half of host memory, between 512 MiB and 32 GiBsbx create
-p PORT, --deny-network HOSTat creation, and -p is ignored when re-attachingsbx run
--skills MODE, --static-mcp NAMES, --profile NAMEat creation onlysbx run
-t IMAGE, --pull POLICYat creation, and --pull is always, missing, or never, default alwayssbx run
-dprints the sandbox id and exits without a sessionsbx run
--rmremoves the sandbox after the agent session exits, new in v0.47.0sbx run

The recording Mac gave m101-demo cpu 10 and memory 32 GiB, the upper bound of the memory clamp. --rm does not work together with --detached, because a detached run has no session to end.

stop, rm, and prune

sbx stop keeps the sandbox and ends its microVM. The capture prints state preserved with the restart command. The docs list what persists across a stop and a restart. That is the installed packages, the Docker images, the configuration changes, the command history, and the workspace files that are not on a mount. The daemon also stops a sandbox on its own. After the capture closed its last session and waited, sbx ls showed m101-demo as stopped, and daemon.log gives the reason.

the daemon stops an idle sandboxtextFull log
$ grep auto-stop daemon.log | grep m101-demo | tail -2
{"time":"<ts>","level":"INFO","msg":"auto-stop grace period expired, stopping runtime","version":"v0.47.0 0411f50ee4700fe7bd37e6e7e3aced563e850ca9","runtime":"m101-demo"}
{"time":"<ts>","level":"INFO","msg":"auto-stopped runtime after last session disconnected","version":"v0.47.0 0411f50ee4700fe7bd37e6e7e3aced563e850ca9","runtime":"m101-demo"}
Cut to the log query and its two lines. The timestamps are masked as <ts>.

sbx run -d against an existing sandbox keeps it running after the sessions disconnect, until you stop or remove it. A kit can declare com.docker.sandbox/long-running@1 for the same effect, as the capabilities show.

sbx rm is the opposite of stop. For a local sandbox it stops the sandbox, removes its containers, and cleans up its Git worktrees. It also deletes the state and the secrets of that sandbox. --force skips the prompt and removes a sandbox with an open SSH connection, and --all removes every local sandbox.

sbx prune removes stopped sandboxes only, because prune never removes a running sandbox. --filter until=168h keeps anything stopped within the last week, and a sandbox whose stop time the daemon cannot report is left alone. --dry-run --json shows both sets before you commit.

a dry run after one stopjsonFull log
{
  "would_remove": [
    {
      "name": "m101-demo-2",
      "agent": "shell",
      "stopped_at": "<ts>",
      "workspaces": [
        "$CAPTURE/fixtures/repo"
      ]
    }
  ],
  "skipped_unknown_stop": []
}
Nothing is cut. m101-demo was still running.
the prune that ends the parttextFull log
$ sbx prune --force
Deleting sandbox m101-demo...
Sandbox 'm101-demo' removed
Deleting sandbox m101-demo-2...
Sandbox 'm101-demo-2' removed
[exit 0]

$ sbx ls --json
{
  "sandboxes": []
}
[exit 0]
The stop of m101-demo before the prune is cut.

Both rm and prune delete the secrets scoped to the sandbox, which sbx secret explains. Figure 2.1 puts the verbs on the edges of one state machine.

Fig. 2.1the four states of a local sandboxstate
The four states of a local sandbox Four states: absent, running, stopped, and removed. sbx create and sbx run move a sandbox from absent to running. sbx stop and the auto-stop of the daemon move it to stopped, and sbx run --name, sbx exec, and sbx ports move it back to running. sbx rm and sbx prune move a stopped sandbox to removed, and sbx rm --force or sbx run --rm move a running one there. The sandboxes named are m101-demo and m101-demo-2 from the capture. absent no row in sbx ls running m101-demo m101-demo-2 removed gone from sbx ls stopped state preserved sbx create sbx run sbx rm --force sbx run --rm sbx stop or auto-stop sbx run --name sbx exec, sbx ports sbx rm sbx prune, stopped only dashed border: no microVM running · double border: no record remains
A sandbox is absent, running, stopped, or removed, and every sbx verb in this section moves it along exactly one edge. Read left to right. Dashed amber arrows are state changes, the names are the capture's two sandboxes, and the dashed box has no microVM running.

Docker Sandboxes (sbx) and Docker Agent (docker-agent) sbx 0.47.0, docker-agent 1.149.0 · bf4169c · 2026-10-07 · Edition 2026.10