Docker Sandboxes vs. Containers for AI Agents

Daily Code Guide Docker News

Docker is positioning Sandboxes as a different isolation boundary for AI coding agents, not as a general replacement for containers. Standard containers isolate processes, filesystems, and network views while sharing the host kernel. Docker Sandboxes instead run agents inside microVMs with their own Linux kernel, filesystem, network environment, and private Docker Engine.

That distinction matters when an agent can install packages, modify a codebase, run services, or execute commands autonomously. The right choice depends on whether the workload is a packaged application or an agent that needs machine-like control while remaining separated from the host.

What changed: a microVM boundary for agents

According to Docker’s comparison of Sandboxes and containers, a conventional container is well suited to running a packaged process. Linux namespaces provide isolated views of resources, while cgroups help control resource use, but the container still shares the host kernel.

A Docker Sandbox adds a virtual-machine boundary around the agent. The agent receives a dedicated kernel, filesystem, network stack, and private Docker Engine. That private Engine allows the agent to build images, run Testcontainers, and start Compose applications without requiring access to the host Docker daemon.

This is different from mounting /var/run/docker.sock into a container. A container with access to the host socket may be able to control the host Docker daemon, mount host paths, or start privileged containers. Sandboxes keep the host daemon and socket outside the microVM.

The distinction does not make a Sandbox an absolute security guarantee. Deliberately shared resources remain exposure points, including mounted workspaces, permitted network destinations, MCP servers, shared skills, and configured credentials.

Ad

When containers remain the better fit

Docker presents standard containers as the practical choice for packaged applications, CI jobs, and short-lived execution. These workloads generally have a defined process boundary and do not need an agent to administer a complete development environment.

Containers can also be the right choice for applications that must integrate closely with an existing container platform. However, the supplied documentation does not provide benchmark-based compatibility or performance comparisons for every Compose, Kubernetes, CI, GPU, editor, or MCP workflow. Teams should validate their specific workflow rather than assume universal compatibility.

Sandboxes are aimed at autonomous agents that need persistent development state, sudo access, package installation, or a private Docker Engine. Installed state remains across Sandbox stops and restarts. Removing the Sandbox deletes the virtual machine contents.

Workspace and lifecycle behavior

The sbx CLI provides commands for starting, stopping, reconnecting to, copying files into, and removing Sandboxes. A typical agent session can be started with:

sbx run claude

When sbx run is used without a workspace path, Docker mounts the current directory. The agent can read, write, and delete files within that directory, including hidden files, configuration files, build scripts, and Git hooks. Administrators should therefore review the directory being exposed before starting an autonomous agent.

A mountless Sandbox is also supported. In that arrangement, files in the Sandbox’s internal working directory persist across stops and restarts, but are deleted when the Sandbox is removed. The relevant lifecycle commands include sbx stop to pause a session, sbx run --name to reconnect, sbx rm to delete it, sbx prune to remove stopped Sandboxes, and sbx run --rm for a throwaway session. The exact behavior is documented in Docker’s Sandbox usage guide.

Removing a Sandbox does not delete files in a host-mounted workspace or other host-side resources. That distinction is important when planning cleanup.

Local and cloud Sandboxes are different

Docker documents both local Sandboxes and Docker-managed cloud Sandboxes, but their capabilities are not interchangeable.

  • Local Sandboxes: use host resources and can use supported host integrations such as GPU, USB, display, and nested virtualization. They persist until removed.
  • Cloud Sandboxes: use Docker-managed resources, do not access host paths or host hardware, and have time-to-live and timeout behavior. Cloud compute is pay-as-you-go.

Cloud Sandboxes support Linux amd64 and arm64 subject to account availability. They can expose ports through public HTTPS URLs, but do not support local-only features such as host workspace paths, bind mounts, GPU, USB, display, nested virtualization, host port bindings, or local model and provider selection.

Moving between local and cloud environments copies a filesystem snapshot. It does not transfer running processes, memory, host-mounted files, managed secrets, or policy configuration. Teams should treat a move as a new execution environment and recheck credentials, network rules, ports, architecture, storage, and expiration behavior.

Network and credential controls

Local Sandbox networking is deny-by-default for outbound TCP traffic. Outbound UDP and ICMP are disabled by default, and DNS uses an internal policy-enforcing resolver. Explicit rules can allow required destinations. The host Docker daemon, direct communication between Sandboxes, and host filesystem access outside explicitly mounted workspaces and shared skills are blocked by default and cannot be enabled through ordinary Sandbox policy configuration.

Credentials are not automatically available to an agent. When configured, Docker can use a host-side proxy to inject credentials into outbound HTTP headers while exposing only a sentinel value inside the Sandbox. OAuth passthrough is a less-isolated option because it can send the real token into the Sandbox.

Docker documents storage in the operating system keychain or, on Linux systems without a Secret Service, in a permission-protected file. Any user or process able to read that fallback file can retrieve the credentials. Host-side storage and proxy-managed injection are preferable to placing API keys directly in the Sandbox, but they do not remove the need to review which services the agent can reach.

Installation and availability

The sbx CLI must be installed and authenticated with sbx login. Docker documents local support for macOS Sonoma 14 or later on Apple silicon, Windows 11 on 64-bit Intel or AMD hardware with Windows Hypervisor Platform, and Ubuntu 24.04 or later on supported 64-bit Intel, AMD, or Arm hardware with KVM enabled. Docker states that Ubuntu derivatives such as Linux Mint and Pop!_OS are not tested or supported.

The CLI can be installed through Homebrew on macOS, WinGet or MSI packages on Windows, and Docker’s package or release-artifact procedures on Ubuntu. Docker Desktop or Docker Engine is not required to use the CLI, although the Ubuntu installation documentation separately describes installing the CLI with Docker Engine.

The supplied documentation describes the CLI and local Sandbox compute as free to use, including commercially. Cloud compute is billed pay-as-you-go, and model-provider charges are separate. Organization-wide management of local Sandbox policies requires a separate paid subscription. The available material confirms that organization-level policy management exists, but does not fully document governance configuration or audit-log behavior.

What you should do

  1. Classify the workload. Use a container for a packaged application, CI job, or short-lived process. Consider a Sandbox when an autonomous agent needs persistent state, sudo, package installation, or private Docker access.
  2. Install the sbx CLI, verify the documented local prerequisites, and sign in with sbx login.
  3. Choose the workspace deliberately. Use a mountless Sandbox for work that should remain inside the VM, or mount only the host directory the agent must modify.
  4. Review network allowlists, MCP servers, shared skills, and credentials before launching the agent.
  5. Avoid unnecessary Docker-socket mounts and broad host filesystem exposure in ordinary containers.
  6. Before moving to the cloud, check hardware, workspace, port, credential, network, storage, expiration, architecture, and billing differences.

Docker Sandboxes change the isolation boundary around an autonomous agent, while containers remain useful for the applications that agent builds or runs. The practical decision is less about choosing one technology universally and more about deciding whether the workload needs a packaged process boundary or a persistent, machine-like environment with host-enforced controls.

Sources

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Ad
Ad
Ad