Manage the lifecycle of isolated microVM sandboxes for AI coding agents using the sbx CLI.
- GitHub stars
- 626
- Files
- 6
- Last commit
- Nov 10, 2026
- License
- Apache-2.0
- Allowed tools
- —
What does the docker-sandboxes-lifecycle skill do?
docker-sandboxes-lifecycle manages the lifecycle of isolated microVM sandboxes for AI coding agents using the sbx CLI.
Summary generated from the skill's SKILL.md.
About the docker-sandboxes-lifecycle skill
Developers who need to run AI coding agents in isolated environments can use this skill to manage the full lifecycle of Docker Sandboxes. It provides direct control over the standalone sbx CLI to create, run, reattach, stop, and remove microVM sandboxes. This is essential for users who want to provide agents like Claude, Gemini, or Cursor with their own filesystem and network while maintaining strict isolation from the host machine.
The skill manages how agents interact with local code through either direct bind mounts or the --clone flag, which creates a private in-container Git repository. It allows for the addition of read-only workspaces to prevent accidental modifications to specific directories. Beyond basic lifecycle management, it enables copying files between the host and the sandbox, executing ad-hoc commands via sbx exec, and managing published ports. Users can also perform bulk cleanup of stopped sandboxes using the prune command with specific time filters.
What an agent can do with it
- 1Isolate an agent from a repositoryAn AI agent can work on a private in-container clone of a Git repository to prevent it from writing directly to your host working tree.
- 2Transfer files to a sandboxMove configuration files or logs between your local machine and the isolated microVM environment.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the docker-sandboxes-lifecycle skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the docker-sandboxes-lifecycle skill in Plugin
/plugin marketplace add docker/skills /plugin install docker-skills@docker
Install the docker-sandboxes-lifecycle skill in Claude Code
~/.claude/skills/docker-sandboxes-lifecycle/SKILL.md
$ npx degit docker/skills/skills/docker-sandboxes-lifecycle ~/.claude/skills/docker-sandboxes-lifecycleInstall the docker-sandboxes-lifecycle skill in Claude Code (project)
.claude/skills/docker-sandboxes-lifecycle/SKILL.md
$ npx degit docker/skills/skills/docker-sandboxes-lifecycle .claude/skills/docker-sandboxes-lifecycleInstall the docker-sandboxes-lifecycle skill in Codex
~/.agents/skills/docker-sandboxes-lifecycle/SKILL.md
$ npx degit docker/skills/skills/docker-sandboxes-lifecycle ~/.agents/skills/docker-sandboxes-lifecycleInstall the docker-sandboxes-lifecycle skill in Gemini CLI
~/.gemini/skills/docker-sandboxes-lifecycle/SKILL.md
$ npx degit docker/skills/skills/docker-sandboxes-lifecycle ~/.gemini/skills/docker-sandboxes-lifecycleInstall the docker-sandboxes-lifecycle skill in Claude.ai
npx degit docker/skills/skills/docker-sandboxes-lifecycle docker-sandboxes-lifecycle && zip -r docker-sandboxes-lifecycle.zip docker-sandboxes-lifecycle # claude.ai → Customize → Skills → + → Create skill → Upload a skill → docker-sandboxes-lifecycle.zip
Automated checks
Ran Nov 14, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachabledocker/skills/skills/docker-sandboxes-lifecycle is public and reachablegithub.com/docker/skills/tree/HEAD/skills/docker-sandboxes-l ↗Pass
- Open source license (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-10github.com/docker/skills/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/docker/skills/blob/HEAD/skills/docker-sandboxes-l ↗Pass
- Pre-approved tools are scopedNo pre-approved tools; the agent asks before using onegithub.com/docker/skills/blob/HEAD/skills/docker-sandboxes-l ↗Pass
SKILL.md
View on GitHubDocker Sandboxes: Local Lifecycle & Workspace Isolation
Overview
Docker Sandboxes (sbx) runs an AI coding agent inside an isolated microVM with
its own filesystem, network, and Docker daemon. This skill owns the local
sandbox lifecycle — creating, reattaching to, listing, stopping, and removing
sandboxes — and the workspace isolation choice (direct bind mount vs.
--clone). It does not cover network policy, credentials, sbxenv.yaml, or
kit authoring — see Related skills.
When to use this skill
Activate this skill when:
- The user wants to start, reattach to, stop, or remove a local
sbxsandbox. - The user wants an agent to work on a repository without giving it a
writable bind mount of the host working tree (
--clone). - The user wants extra read-only (or write-restricted) workspaces mounted alongside the primary one.
- The user is copying files between host and sandbox, publishing a sandbox
port, or running an ad-hoc command inside a sandbox (
sbx exec). - The user wants to clean up stopped sandboxes (
sbx prune) or remove a specific one (sbx rm), with the destructive consequences understood.
Do not use this skill when
Do not use this skill when:
- The task is running
docker agent run --sandboxor managing itsdocker agent sandboxallowlist — usedocker-agent-run. If the CLI is unclear, establish whether the user runs Docker Agent or standalonesbxbefore choosing commands. - The task is about what a sandbox can reach on the network or which
credentials it uses — use
docker-sandboxes-network-credentials. - The task is authoring or running a declarative
sbxenv.yamlfile — usedocker-sandboxes-env. - The task is authoring, packaging, signing, or composing a kit
spec.yaml— usedocker-sandboxes-kits. - The task is about
sbx --cloud(Docker Cloud Sandboxes) — out of scope for this skill set, which covers the local daemon only.
Core guidance
Creating vs. running
- Use
sbx run AGENT [PATH...]to create-if-needed and attach in one step. Usesbx create AGENT [PATH...]to create without attaching, thensbx run --name SANDBOXto attach later. Pass--detached/-dtosbx runto print the sandbox ID and exit without an interactive session.sbx run shell # create (if needed) and attach, cwd mounted sbx create shell . # create only, cwd mounted, do not attach sbx run --name my-sandbox # reattach later AGENTis a built-in name (claude,codex,cursor,devin,docker-agent,gemini,opencode,shell) or a sandbox kit reference (local directory, ZIP, git, or OCI). A relative local kit reference MUST be an explicit path (./my-kit, a parent-relative.zippath) — a baremy-kitis read as an agent/sandbox name, never a directory beside the cwd.- Omitting the path is not the same for every subcommand.
sbx run claudewith no path mounts the current directory.sbx create claudewith no path mounts nothing at all — the agent then works only in the container's own filesystem. Always pass a path explicitly withsbx createif you intend to give the agent a workspace. - Prefer
--nameto reattach; a bare positional name still works but is deprecated.sbx run --name NAME(agent positional optional, read from the sandbox's own spec) is the recommended form. A baresbx run NAME— a positional that is neither a known agent nor an explicit kit reference — is still accepted as a legacy re-attach shorthand, but prints a deprecation warning ("sbx run NAMEis deprecated; usesbx run --name NAMEinstead") and may be removed in a future release. Always write--nameexplicitly rather than relying on the legacy form.sbx run --name existing-sandbox # reattach, agent read from spec sbx run claude --name existing-sandbox # reattach, verify expected agent
Workspace isolation: bind mount vs. --clone
- Default (bind mount): the workspace path is mounted read/write inside the sandbox at the same path as on the host. The agent can write directly to your working tree.
--clone(creation-time only): the agent runs against a private in-container clone of the host Git repository. The host repo is mounted read-only; the agent's commits land in the in-container clone and are reachable from the host via asandbox-<name>git remote — fetch or pull from it to bring commits back.sbx create --clone --name demo claude . # on the host, later: git fetch sandbox-demo--clonehas real preconditions, checked at creation time, and fails loudly if any is unmet:- an explicit
PATHmust be given (there must be a workspace to clone from); - that path must be inside a Git repository;
- it must NOT be a Git worktree (the in-container clone cannot follow a
worktree's
.gitpointer out to a common dir elsewhere); - its
.gitmust be a real directory, not a file (a submodule or a--separate-git-dirsetup points.gitelsewhere, which the read-only source mount would not include).
- an explicit
--cloneonsbx runwhen reattaching is a no-op ONLY on a sandbox already created in clone mode — it re-validates nothing new and simply keeps running the existing in-container clone. Passing--clonewhile reattaching to a sandbox that was created without it (a plain bind-mounted sandbox) is not a silent no-op: it fails with an error telling you to recreate the sandbox withsbx create --clone .... Neither form can convert an existing sandbox's mode after creation.- Removing or pruning a clone-mode sandbox permanently discards every
commit the agent made that was never fetched back to the host — the
in-container clone lives on the sandbox's own filesystem and is deleted
with it. Before removing a clone-mode sandbox, fetch its work first:
Fetching populates two refspecs: the ordinarygit fetch sandbox-demorefs/remotes/sandbox-demo/*(deleted along with the remote when the sandbox is removed) and a survivor copy atrefs/sandboxes/demo/*(outside the remote namespace, so it is not deleted when the remote goes). Recover a branch from the survivor copy after removal with:git branch <local-name> refs/sandboxes/demo/<branch>sbx rm/sbx pruneprint this warning automatically for any clone-mode sandbox they are about to remove; read it before confirming, don't suppress it with--forceout of habit. - Additional workspaces are extra positional paths after the first. Append
:roto mount one read-only.:roblocks writes, not reads — the sandbox can still read every file under a:romount; it is not a way to hide sensitive content, only to stop the sandbox from modifying it. A read-only argument may name a single file rather than a directory, holding just that one path out of reach for writes inside a workspace the sandbox can otherwise write.
Never mount a secrets/credentials file this way (sbx run claude . /path/to/docs:ro:roor otherwise) — a read-only mount still lets the sandbox (and, through it, the proxy-less agent process) read the secret in the clear. Use the credential store instead; seedocker-sandboxes-network-credentials.
Reattaching, stopping, and removing
sbx lslists sandboxes with agent, status, published ports, and workspace (--json,-q/--quietfor scripting).sbx stop SANDBOX [SANDBOX...]stops without removing; state is retained and the sandbox restarts withsbx run --name.sbx rm [SANDBOX...] [--all] [--force]removes sandboxes, their containers, Git worktrees, state, and sandbox-scoped secrets. This cannot be undone, and for a clone-mode sandbox it discards every unfetched commit (see above). Only use--forcewhen you have already reviewed what will be destroyed and consented — for scripted teardown of resources this session itself created and uniquely named, not as a default habit.sbx prune [--dry-run] [--filter until=VALUE] [--force]removes only stopped sandboxes — a running sandbox is never touched — but this is still a destructive, irreversible bulk removal: every matching stopped sandbox's state, secrets, and (for clone-mode sandboxes) any unfetched commits are gone. Always preview with--dry-runfirst and read the clone-commit warning it prints before removing for real; do not pass--forceas a default.- Current source flag is
--filter until=VALUE, notsince=.VALUEmay be an RFC 3339 timestamp, a Unix timestamp, or a Go duration relative to now (e.g.until=168hkeeps anything stopped within the last week — i.e. prunes what stopped before that point). This is a source-only behavior at the pinned commit that differs from some installed builds: an older installedsbxmay still advertise--filter since=DURATIONas a legacy alias; preferuntil=and treatsince=as legacy-only if your installed--helpoutput does not showuntil=.
sbx prune --dry-run --filter until=168h # after reviewing the dry-run output and any clone-commit warnings: sbx prune --filter until=168h- Current source flag is
Copying files and running ad-hoc commands
sbx cp SRC DSTcopies between host and sandbox; exactly one side must beSANDBOX:PATH. Copying between two sandboxes is not supported.sbx cp ./config.json my-sandbox:/home/agent/ sbx cp my-sandbox:/home/agent/output.log ./sbx exec [flags] SANDBOX COMMAND [ARG...]runs a command in a sandbox (starting it first if stopped); flags mirrordocker exec(-it,-d,-u,-w,-e,--env-file,--privileged).sbx exec -it my-sandbox bash sbx exec -u root my-sandbox apt-get updatesbx ports SANDBOX [--publish SPEC] [--unpublish SPEC]manages published ports after creation;-p/--publishonsbx create/sbx runonly takes effect when the sandbox is created, not on reattach.
Sizing and naming
--cpus(0 = auto: all host CPUs) and--memory/-m(default 50% of host memory, clamped 512 MiB–32 GiB) are create-time-only knobs.--namesets the sandbox name (default<agent>-<workdir>); at least two characters, starting with a letter or number, letters/numbers/hyphens/ periods only, at most 63 ASCII characters, ending in a letter or number;defaultis reserved.
Related skills
-
For
docker agent run --sandboxanddocker agent sandboxcommands, usedocker-agent-run. -
For network egress policy and service/registry credentials, use
docker-sandboxes-network-credentials. -
For declarative, checked-in
sbxenv.yamlenvironments that wrap this same create/run/rm lifecycle, usedocker-sandboxes-env. -
For authoring or composing the kit
spec.yamlanAGENTreference can point to, usedocker-sandboxes-kits.
References
references/sources.md— provenance for every rule above (help captures, source paths, docs URLs).
Assets
- None.
Checks
checks/verification.md— Verification runbook for sandbox lifecycle commands (unexecuted runbook; run manually with an isolated--app-name, never with--forceexcept consented cleanup of the runbook's own uniquely-named test sandboxes).
Files in this skill
6docker-sandboxes-lifecycle skill questions
How do I install the docker-sandboxes-lifecycle skill in Claude Code?
Run npx degit docker/skills/skills/docker-sandboxes-lifecycle ~/.claude/skills/docker-sandboxes-lifecycle. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the docker-sandboxes-lifecycle skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
How do I run an agent in a sandbox without giving it write access to my host files?
You can use the --clone flag during creation to run the agent against a private in-container clone of your Git repository. The host repository remains read-only.
What is the difference between sbx run and sbx create?
sbx run creates a sandbox if it doesn't exist and immediately attaches to it, whereas sbx create only creates the sandbox without attaching.
Will I lose my agent's work if I delete a clone-mode sandbox?
Yes, deleting a clone-mode sandbox permanently discards any commits the agent made that were not fetched back to the host.
How can I mount a directory as read-only in a sandbox?
Append ':ro' to the end of the workspace path argument.