Running an autonomous coding agent like Claude Code, Cursor, Codex, or Kiro directly on your host workstation gives that agent the same filesystem, network, and credential reach as your own user account. A single prompt injection buried inside an untrusted repository, dependency script, or issue thread can read ~/.ssh, exfiltrate environment variables, or invoke destructive Model Context Protocol (MCP) tools before you notice a terminal command ran.
Standard containers were built to isolate predictable application workloads, whereas AI agents act as autonomous operators that decide what code to write, which packages to pull, and which external endpoints to query. In mid-November 2026, Docker shipped Docker Sandboxes v0.54.0 alongside its Docker AI Governance architecture, wrapping each coding agent inside a dedicated microVM with enforceable network proxies, mount policies, Cedar-based MCP tool rules, and structured SIEM audit logs.
This guide walks through setting up Docker Sandboxes v0.54.0 from scratch, locking down outbound network traffic with a default-deny baseline, building reusable sandbox templates via snapshots and Dockerfiles, enforcing Cedar policies across the MCP Gateway, and migrating past the breaking SSH and Git transport changes introduced in the November 2026 releases. All commands, settings keys, and policy syntax below are drawn from the official Docker Sandboxes release notes, Docker AI Governance documentation, and Mohammad-Ali A'rabi's v0.51+ toolchain walkthrough.
A standard docker run container shares the host Linux kernel (or the shared Linux VM kernel inside Docker Desktop on macOS and Windows). If you grant an agent inside a regular container access to /var/run/docker.sock so it can build and test container images, that agent effectively gains root-equivalent control over the host Docker daemon.
Docker Sandboxes solves that architectural problem by giving each sandbox its own lightweight microVM managed by the sbx CLI and background sandboxd daemon. Every sandbox runs an isolated kernel, a private internal Docker Engine, a dedicated filesystem boundary, and a host-enforced network proxy.
When you combine Docker Sandboxes with Docker AI Governance and Docker Hardened Images (DHI), the security model splits cleanly across three enforcement layers and a verifiable supply chain:
That microVM approach contrasts with cluster-level sandboxing strategies like Google's Agent-Substrate and gVisor donation to the CNCF, giving individual developer laptops and cloud sandboxes a local-first enforcement boundary.
Docker AI Governance layers covering Sandbox Policies, Cedar MCP Tool Governance, and SIEM Audit Logs
Before installing docker-sbx, confirm your workstation meets the hardware virtualization requirements for local microVMs:
/dev/kvm available and your user account added to the kvm group.
Note that the sbx CLI runs its own microVM runtime and does not require a host Docker Engine just to launch sandboxes. You only need a host Docker Engine or Docker Desktop installation if you plan to build custom sandbox templates from a Dockerfile using docker build and docker image save.
On Ubuntu 24.04 or 26.04, configure Docker's official apt repository without auto-installing the full container engine, then install the docker-sbx package and verify /dev/kvm membership:
BashCopy
curl -fsSL https://get.docker.com | sudo REPO_ONLY=1 sh
sudo apt update
sudo apt install -y docker-sbx
sudo usermod -aG kvm "$USER"
On macOS with Apple silicon, install the CLI directly from Docker's Homebrew tap:
BashCopy
shell
brew trust docker/tap
brew install docker/tap/sbx
plaintext
Once installed, check the binary version (which prints the client release without starting sandboxd) and authenticate with your Docker account:
BashCopy
shell
sbx --version
sbx login
If you are upgrading an existing installation to v0.54.0 (released November 16, 2026), execute two mandatory migration steps right away. First, refresh your generated SSH configuration so older OpenSSH clients are protected against crafted host or username command injection:
BashCopy
shell
sbx setup ssh
sbx --cloud setup ssh
Second, if you ever run sbx as root on Unix, note that v0.54.0 ignores inherited path overrides (HOME, XDG_CONFIG_HOME, XDG_STATE_HOME, XDG_CACHE_HOME, SANDBOXES_STORAGE_ROOT, and DOCKER_SANDBOXES_API) when running as root, locking root execution to root's registered home directory. Stop any older root daemon using custom storage paths before upgrading.
To enable Docker Hardened Image templates across your sandboxes, note that the legacy DOCKER_SANDBOXES_USE_DHI environment variable was retired in v0.53.0. Set the persistent configuration key instead:
BashCopy
plaintext
sbx settings set platform.images.useDHI true
markdown
By default, an unconstrained coding agent can reach arbitrary external domains. Before spinning up a workspace, initialize a global default-deny network baseline so every outbound connection must pass an explicit allow rule.
If you have used Docker Sandboxes previously and want to clear stale rules first, run sbx policy reset (which reports how many user-added and approval-granted rules will be removed) and then initialize the deny-all preset:
BashCopy
plaintext
sbx policy reset
sbx policy init deny-all
sbx policy ls
Because network policies are enforced by the host-side sandbox proxy instead of inside the guest VM, an agent cannot bypass them by editing /etc/hosts, changing iptables, or modifying environment variables. You can verify the effective policy from your host terminal before starting any agent:
BashCopy
plaintext
sbx policy check network github.com:443
sbx policy check network api.anthropic.com
In v0.54.0, sbx policy check network names the exact rule that permitted or blocked a target and explains when an HTTP-level policy check (sbx policy check http) is required. Keep in mind that v0.53.0 updated HTTP policy matching to treat ASCII letters in URL paths and query parameter names and values case-insensitively, so audit any custom HTTP rules that previously relied on uppercase or lowercase path distinctions.
Also check sbx policy --help if you block specific hostnames on CDN-backed origins: when an allowed hostname and a denied hostname share the same underlying IP address, IP-layer connection checks can overlap unless inspected at the HTTP/TLS proxy layer.
Starting in v0.51.0, built-in agent names resolve to published Kit v3 images hosted at docker.io/sbx/NAME:latest, covering claude, codex, cursor, devin, docker-agent, opencode, kiro, copilot, droid, and shell. Note that the built-in gemini agent name was retired in v0.53.0.
You can launch a sandbox in two workspace modes:
--clone) clones your Git repository into a private working copy inside the microVM. You review and fetch commits back to the host only after inspecting what the agent changed.
In v0.54.0, clone-mode Git transport received a major security upgrade. Previously, fetching from the sandbox-NAME Git remote used an unauthenticated localhost TCP port (9418), which exposed the repository history to other local user accounts on multi-user hosts. Version 0.54.0 routes sandbox-NAME fetches over the Unix daemon socket restricted strictly to your host user account and blocks publishing TCP port 9418. Only enable legacy TCP transport ( sbx settings set clone.legacyTcpRemote true) if you use a non-standard Git client that ignores custom uploadpack settings.
Let's create an isolated shell sandbox named sbx-workspace mounted to the current project directory, or add --clone for a private Git copy:
BashCopy
shell
sbx create --name sbx-workspace shell .
sbx run --name sbx-workspace
When you need to attach a secondary reference repository as read-only so the agent can read shared libraries without modifying them, pass PATH:TARGET:ro at creation time:
BashCopy
shell
sbx create --name sbx-multi --workspace ../shared-lib:/workspace/shared-lib:ro shell .
Once inside sbx-workspace, check the guest operating system and its configured apt sources. Even if your host machine runs Ubuntu 26.04 or macOS, the default shell kit runs Debian 13 (Trixie):
BashCopy
shell
cat /etc/os-release
find /etc/apt -maxdepth 2 -type f ( -name '.list' -o -name '.sources' ) -exec cat {} +
In the default Debian 13 shell kit, package metadata and security updates pull from deb.debian.org, while Docker Hardened Image packages pull from dhi.io. If you run sudo apt update right now under the deny-all policy, the proxy will reject the connection (often surfacing as a 403 error followed by a misleading "repository is not signed" warning from apt).
Open a second terminal on your host and allow only the package mirrors and LLM API endpoints required for that specific sandbox:
BashCopy
shell
sbx policy allow network --sandbox sbx-workspace 'deb.debian.org,dhi.io,api.anthropic.com'
sbx policy check network --sandbox sbx-workspace deb.debian.org
Back inside the sandbox terminal, sudo apt update and package installations will now succeed cleanly while every other domain on the internet stays blocked.
Installing heavy toolchains like Node.js, Rust, Python data science stacks, or TeX Live inside a fresh sandbox every morning wastes bandwidth and disk I/O. Docker Sandboxes supports two workflows for turning a configured environment into a reusable template, mirroring the difference between docker commit and docker build.
Comparison flowchart of sbx template save snapshots and Dockerfile tar import into the microVM store
If you installed packages interactively inside sbx-workspace and want to freeze that exact root filesystem for future projects, stop the sandbox from your host terminal and save a template snapshot:
BashCopy
shell
sbx stop sbx-workspace
sbx template save sbx-workspace my-team-stack:v1
sbx template ls
Keep three security boundaries in mind when snapshotting:
/home/agent inside the microVM filesystem sbx template save or manage secrets exclusively via sbx secret.
To spin up a brand-new sandbox from your saved snapshot without querying a remote registry, pass --template and --pull never:
BashCopy
shell
sbx create --name sbx-fast-clone --template my-team-stack:v1 --pull never shell .
sbx run --name sbx-fast-clone
Snapshots are fast, but they do not document which package versions were installed. For version-controlled team environments, write a Dockerfile that extends Docker's official standalone base image (docker.io/sbx/shell-image:latest, or docker.io/sbx/shell-docker-image:latest if your agent needs an internal Docker daemon). Do not use the old docker/sandbox-templates:shell tag, which was retired in v0.51.0.
Note one important OS difference documented in November 2026 testing: while the interactive shell kit runs Debian 13, the standalone docker.io/sbx/shell-image:latest base image runs Ubuntu 26.04 (Resolute). Always extend an official sbx/ base image instead of a plain ubuntu:26.04 image so the mandatory agent user, init wrappers, and sandbox hooks remain intact.
Create a sbx-template/Dockerfile:
DockerfileCopy
docker
FROM docker.io/sbx/shell-image:latest
USER root
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nodejs npm python3-pip ripgrep jq curl && rm -rf /var/lib/apt/lists/*
USER agent
Always switch back to USER agent at the end of the Dockerfile so the coding agent does not execute as root inside the microVM.
Because Docker Sandboxes maintains its own microVM image store completely separate from your host Docker Engine, running docker build alone does not make the image visible to sbx. Export the built image to a .tar archive and import it into the sandbox image store with sbx template load:
BashCopy
shell
docker build -t my-team-stack:v2 ./sbx-template
docker image save my-team-stack:v2 -o my-team-stack-v2.tar
sbx template load my-team-stack-v2.tar
sbx create --name sbx-declarative --template my-team-stack:v2 --pull never shell .
To monitor how much disk space your accumulated templates, containers, and volumes consume, run the disk usage command introduced in v0.53.0:
BashCopy
shell
sbx df --verbose
sbx template ls --all --digests --no-trunc
Once an AI agent is running inside its microVM, you need controlled ways to expose local dev servers, inject API credentials without leaking plaintext strings, and govern which MCP tools the agent is allowed to invoke.
Version 0.54.0 deprecated the legacy sbx ports command in favor of structured sbx port subcommands that work identically across local and cloud sandboxes:
BashCopy
shell
sbx port publish sbx-declarative 3000:3000
sbx port ls sbx-declarative
sbx port unpublish sbx-declarative 3000:3000
If you omit the host port (sbx port publish sbx-declarative :3000), Docker Sandboxes assigns an available loopback port automatically. Starting in v0.53.0, unpublishing an automatically assigned port keeps it unpublished across sandbox restarts (fixing CVE-2026-126330).
Never pass raw API keys on the command line where they persist in shell history or ps output. Use --value-stdin with an explicit destination host so the sandbox proxy substitutes the credential only on requests to that exact domain:
BashCopy
shell
printf '%s' "$ANTHROPIC_API_KEY" | sbx secret set-custom anthropic_key --value-stdin --host api.anthropic.com
Starting in v0.51.0, custom secrets without an explicit destination host no longer substitute credentials, preventing accidental token leakage to untrusted endpoints.
When agents connect to external systems through the Model Context Protocol, making an MCP server available should not grant blanket permission to run destructive tools. Docker AI Governance routes MCP calls through the Docker MCP Gateway and evaluates organization rules written in the Cedar policy language.
To inspect which MCP mode (static or dynamic) and servers are attached to a sandbox versus registered on your host, run:
BashCopy
shell
sbx inspect sbx-declarative
sbx mcp ls
You can also prefix MCP tool names with their server identifier to prevent naming collisions across multiple servers:
BashCopy
plaintext
sbx settings set mcp.useServerNamePrefixes true
In Docker AI Governance, MCP requests are denied by default when policy enforcement is active unless a Cedar permit rule matches. For example, to allow agents to invoke only read-only tools on an internal MCP server named internal-tracker, define a Cedar policy checking the tool's readOnly annotation:
cedarCopy
rego
permit (principal, action == MCP::Action::"invokeTool", resource)
when {
resource in MCP::Server::"internal-tracker" &&
resource.readOnly == true
};
As GitLab 19.6's new MCP governance controls also highlight, tool annotations like readOnly are supplied by the MCP server metadata, so combine Cedar tool policies with network-level restrictions. Keep one architectural boundary clear: Docker's Cedar MCP policies apply to traffic routed through the Docker MCP Gateway. If an agent inside a sandbox connects directly to a remote HTTP MCP server on its own, that connection is governed by the sandbox's outbound network policy instead.
Diagram of a microVM coding agent connecting through a Cedar MCP policy gate and Unix Git socket
If your team already knows standard Docker commands, the table below maps everyday container workflows to their sbx microVM equivalents alongside common v0.54.0 troubleshooting fixes.
| Workflow / Issue | Standard Docker CLI | Docker Sandboxes ( v0.54.0 ) |
Key Isolation / Troubleshooting Detail |
|---|---|---|---|
| Create & enter environment | docker create /docker run -it |
sbx create /sbx run |
Launches a dedicated microVM with its own kernel and Docker Engine |
| Run one-off command | docker exec |
sbx exec (no--detach-keys or--privileged ) |
v0.53+ removed--detach ,--privileged , and--detach-keys |
| Snapshot filesystem | docker commit |
sbx template save <sbx> <tag> |
Excludes mounted workspace; does not copy network policies |
| Import Dockerfile image | docker build (shared store) |
docker image save +sbx template load |
MicroVM image store is separate from host Docker Engine |
| Publish container ports | docker run -p 8080:80 |
sbx port publish <sbx> 8080:80 |
Dynamic ports can be added or removed without recreating the sandbox |
| Outbound firewall rules | Custom iptables / network plugins |
sbx policy init deny-all &sbx policy allow |
Enforced at host proxy; agent cannot override rules inside guest |
| Corporate proxy TLS drop | Custom CA certs in daemon | sbx settings set tls.postQuantumKeyExchange false |
Fixes Zscaler, Palo Alto, or F5 proxies dropping PQ key exchanges |
| Clone-mode Git fetch | Manual SSH / volume mount | git fetch sandbox-<name> |
Uses user-restricted Unix daemon socket in v0.54.0 (blocks TCP 9418) |
| Check disk & diagnostics | docker system df |
sbx df --verbose &sbx diagnose --format json |
JSON diagnostics include stable check id fields for CI scripts |
Two operational issues frequently trip up enterprise rollouts on corporate networks or Linux workstations:
Docker Sandboxes enables post-quantum TLS key exchange by default (tls.postQuantumKeyExchange = true). Some enterprise TLS-inspecting firewalls and proxies (including older Zscaler, Palo Alto Networks, and F5 configurations) drop or stall handshakes that advertise post-quantum key exchange or ML-DSA signatures. If sbx login or kit pulls hang behind a corporate proxy, disable post-quantum key exchange in v0.54.0 and restart the daemon:
BashCopy
shell
sbx settings set tls.postQuantumKeyExchange false
sbx daemon restart
Similarly, if your laptop frequently switches between office Wi-Fi and split-tunnel VPNs, Docker Sandboxes automatically closes stalled outbound connections after 30 seconds so agents can reconnect cleanly. You can tune that threshold with sbx settings set egress.stalledConnectionTimeoutSeconds 15 followed by sbx daemon restart.
When automating sandbox checks in CI or troubleshooting a reluctant local daemon, use structured JSON output from sbx diagnose (introduced in v0.54.0) and match on the stable id field instead of the display name:
BashCopy
shell
sbx diagnose --format json | jq '.checks[] | select(.status != "pass") | {id, status, message}'
If sandboxd ever stops responding on Linux or macOS, you can dump live goroutine stacks without killing active agent sessions by sending SIGUSR1 to the daemon (kill -USR1 $(pidof sandboxd)), or run sbx diagnose --upload to capture rotated crash logs with usernames and home-directory paths automatically redacted.
Finally, once your local kit and network policies are tested, you can move workloads to Docker-managed cloud sandboxes or schedule recurring background tasks without leaving your laptop online:
BashCopy
shell
sbx --cloud schedule create --name nightly-audit --workdir /workspace --every 24h sbx/claude -- "run security audit"
sbx --cloud schedule ls
Combining --clone mode on local repositories, a deny-all outbound proxy baseline, Cedar MCP gateway rules, and version-controlled sbx/shell-image templates gives coding agents the freedom to build, test, and refactor inside a microVM while keeping your host credentials and production networks out of reach.
Originally published on Mango Developer.