TL;DR
- Docker Sandboxes fits better when you run Claude Code or Codex yourself, the agent builds containers, or you want your project folder shared live.
- VirtX fits better when your own Python, Node.js or Rust program starts the sandboxes.
- Docker's SDK, for JavaScript and TypeScript, creates cloud sandboxes only and needs a Docker Agentic Platform subscription.
- One VirtX program runs on your machine, your own server or VirtX cloud by changing one line, with no account needed locally.
A coding agent writes code and then runs it, so the code that executes on your machine is code no person has read. A sandbox is a separate environment where that code can run without reaching your files, your network or your credentials. One common kind today is a microVM, a small virtual machine that starts in seconds and has its own operating system kernel, the core that sits between programs and the hardware.
Docker’s answer is Docker Sandboxes. This post compares it with VirtX, the microVM runtime we build, so each side below names where the other fits better. It uses Docker’s documentation as checked on 30 November 2026 and shows what each tool isolates, who controls the sandbox, where it runs, and which one suits a developer running an agent versus a product that starts sandboxes.
How a microVM sandbox isolates an agent from your machine
A container shares the host’s Linux kernel with every other container on the machine, so one kernel flaw can reach all of them. A microVM boots its own guest kernel on top of a hypervisor, the layer that runs virtual machines, so code inside it talks to a kernel no other workload uses. Docker Desktop already runs containers inside one Linux virtual machine on macOS and Windows, but those containers still share that machine’s kernel.
Both products in this post use the microVM model. Each sandbox starts from an OCI image, the standard container image format that Docker Hub and other registries serve, and anything an agent installs or breaks stays inside that sandbox, except files it writes to a folder shared with your machine, which Docker does with the project folder unless you use Clone mode. VirtX builds its microVMs on libkrun, a library for running them, with KVM on Linux, Hypervisor.framework on macOS or the Windows Hypervisor Platform on Windows.
Our earlier posts go deeper on the isolation itself: MicroVM vs Container compares the two models, and MicroVM: How a Lightweight Disposable Virtual Machine Works explains how one works. AI Agent Sandbox: What It Is and When You Need One explains why agents need one, and Python Sandbox: Where to Run Code Your AI Agent Wrote walks through the Python case. From here the question is how each product puts that isolation to work.
How Docker Sandboxes put a coding agent in a microVM
Docker Sandboxes runs each agent session in its own microVM, either on your machine or on Docker-managed cloud infrastructure, and the same sbx command line tool manages both. You start an agent with one command, such as sbx run claude or sbx run codex, and it works inside a full Linux environment you can stop and come back to.
Suppose we have a platform team at a mid-size fintech whose developers each run Claude Code on a laptop. Docker’s architecture suits that setup, with four choices a developer notices day to day:
- The project folder is shared live with the sandbox, so the agent’s edits appear on the host as they happen.
- All outbound TCP traffic goes through a proxy on the host that applies network policy and injects credentials, so the real keys stay outside the sandbox.
- Each sandbox runs its own Docker daemon, so the agent can build images and start containers without reaching the host’s Docker.
- Local sandboxes persist until someone removes them, while cloud sandboxes expire after one hour by default.
The sbx tool and local sandboxes are free to use once you sign in with a Docker account, and cloud sandboxes are metered by the second. Local sandboxes need hardware virtualization on the host: Apple silicon with macOS Sonoma 14 or later, Windows 11 on a 64-bit Intel or AMD processor with the Windows Hypervisor Platform turned on, or Ubuntu 24.04 or later with KVM and your user in the kvm group.
How VirtX works when your own program starts the sandbox
VirtX is a library you call from code. You install it with pip install virtx, npm install @brekkylab/virtx or cargo add virtx, then create a sandbox, run commands in it and remove it, all as function calls. Whatever a sandbox installs or changes is gone when you remove it, unless it wrote to a volume you kept.
Suppose the same fintech adds a feature where an assistant writes a Python script for each customer’s spreadsheet. The product itself has to start a sandbox for every request, so it needs a call in code rather than a command someone types. At creation you set the CPUs, memory, disk, outbound network and exposed ports, and network=False cuts outbound connections and DNS lookups.
Where the sandbox runs is one line of the client. Client.spawn() starts a server on your machine, and Client.connect(...) points at a server you run with virtx-server-tcp or at VirtX cloud, with the rest of the program unchanged. A local server runs on Linux with KVM, on Apple silicon Macs, or on Windows 11 with an x86_64 processor, and the guest is always Linux.
Local use needs no account and no Docker daemon, and the VirtX code is Apache-2.0. The next section puts both products side by side.
Docker Sandboxes next to VirtX across ten checks as of 30 November 2026
The table compares the two across isolation, who it is built for, control, location, cost, sign-in, license, Docker inside the sandbox, project files and what is left after the run. Docker’s column follows its documentation and VirtX’s column follows ours, both read on 30 November 2026.
| Check | Docker Sandboxes | VirtX |
|---|---|---|
| Isolation | microVM with its own kernel per sandbox | microVM on libkrun with its own kernel per sandbox |
| Built for | Running coding agents such as Claude Code and Codex | Programs and agents that start sandboxes from code |
| Control from code | SDK and REST API for cloud sandboxes, with a Docker Agentic Platform subscription | Python, Node.js and Rust SDKs for every server type |
| Where it runs | Your machine or Docker-managed cloud | Your machine, your own server or VirtX cloud |
| Cost to start | Free sbx locally, cloud metered by the second |
Free locally |
| Sign-in for local use | Docker account | None |
| License | All rights reserved, Docker Inc. | Apache-2.0 |
| Docker inside the sandbox | Private Docker engine in each sandbox | No Docker engine of its own |
| Project files | Host folder shared live, or Clone mode: a read-only mount with a private clone inside | Files copied in with file calls, or kept in volumes |
| After the run | Local: persists until removed. Cloud: expires after one hour by default | Removed by sandbox.remove() or when a local server exits; volumes keep files |
Three rows separate the two for most teams. Docker’s SDK and API need a Docker Agentic Platform subscription, and the SDK is written for JavaScript and TypeScript, so any other language calls the REST API directly for cloud sandboxes, or runs the sbx command for local ones. Docker also publishes sbx under an all-rights-reserved license, while VirtX is Apache-2.0. The third row is sign-in, because local sbx needs a Docker account and local VirtX does not.
Where Docker Sandboxes fit better than VirtX
Docker Sandboxes fit better when a person runs an off-the-shelf coding agent at a keyboard, and VirtX has limits of its own that a team should weigh before choosing it.
Pick Docker Sandboxes when:
- You run Claude Code, Codex or Copilot yourself.
sbx run claudestarts the agent inside the sandbox, while VirtX has no launcher like it. VirtX’s Claude Code and Codex plugin is a skill that teaches the agent to write VirtX code, and it does not run the agent inside a VM. - The agent builds and runs containers. Each Docker sandbox has its own Docker engine, while a VirtX sandbox has no Docker engine of its own.
- You want edits to appear live in your project folder. VirtX copies files in with file calls or keeps them in volumes.
Weigh these VirtX limits:
- A Dockerfile is read as a one-stage recipe with only
FROM,RUN,ENV(in theENV key=valueform) andWORKDIR, and noASstage name, so multi-stage builds are not supported. - A local server removes its sandboxes when your program ends, so sandboxes that last need your own server or VirtX cloud.
- On macOS a local server needs Apple silicon, so an Intel Mac has to use your own server or VirtX cloud.
- VirtX cloud is currently in early access, so apply at virtx.sh to get access.
Running one VirtX program on a local server or on VirtX cloud
The run function below works against any VirtX server, and only the line that creates the client changes. It pulls a Python image, boots a sandbox with outbound network off and 1 GiB of memory, runs a short script with a ten-second limit, and removes the sandbox. The code is written for VirtX 0.3.0.
import asyncioimport os
from virtx import BearerAuth, Client
AGENT_SCRIPT = """import socket, sys
print("python", sys.version.split()[0])try: socket.create_connection(("1.1.1.1", 53), timeout=3) print("network: reachable")except OSError as err: print("network: blocked,", err)"""
async def run(client: Client) -> None: await client.pull_image("python:3.12-slim").complete() sandbox = await client.create_sandbox( "python:3.12-slim", network=False, memory_mib=1024 ) try: cmd = ["python3", "-c", AGENT_SCRIPT] code = await sandbox.exec(cmd, timeout_ms=10_000).complete(print=True) print("exited", code) finally: await sandbox.remove()
async def main() -> None: print("--- local server ---") async with Client.spawn() as client: await run(client)
print("--- VirtX cloud ---") auth = BearerAuth(os.environ["VIRTX_API_KEY"]) async with Client.connect("https://cloud.virtx.sh", auth) as client: await run(client)
asyncio.run(main())Run on an Apple silicon Mac with VirtX 0.3.0, the local half printed:
--- local server ---python 3.12.16network: blocked, [Errno 101] Network is unreachableexited 0The script prints the Python version and then tries to open a connection to a public address. With network=False that attempt fails, and the script prints the error it got. The second client is the only difference between the two runs, and a server you run yourself needs the same single change after virtx login, as the quick start shows.
Choosing a microVM runtime for your next coding agent project
Docker Sandboxes and VirtX share the same isolation idea, a microVM with its own kernel for every sandbox, and they differ in who starts the sandbox. Choose Docker Sandboxes when a person runs Claude Code or Codex and wants the project folder shared live. Choose VirtX when a program starts the sandboxes from Python, Node.js or Rust and you want the same code to run on a laptop, on a server you run, or on a hosted service.

To try VirtX, run pip install virtx and the local half of the program above on your machine, then read how to set CPUs, memory, network and ports for your own workload.
FAQs
What is a Docker sandbox?
Docker Sandboxes is Docker’s product for running AI coding agents in isolated microVMs, and you start one with a command such as sbx run --name my-sandbox claude. The phrase is also used for any container started with Docker to run untrusted code, which shares the host’s kernel instead of having its own.
Can Docker Sandboxes run code from a Python program?
Docker’s SDK is written for JavaScript and TypeScript and creates cloud sandboxes, so a Python program calls Docker’s REST API for cloud sandboxes, or runs the sbx command for local ones. VirtX has Python, Node.js and Rust SDKs that work against a local, a self-run and a hosted server.
Does a VirtX sandbox need Docker installed?
No. VirtX reads OCI images itself and boots them in a microVM, so there is no Docker daemon to install or keep running. A Dockerfile works as a one-stage recipe with FROM, RUN, ENV (in the ENV key=value form) and WORKDIR only, with no AS stage name.
Can I move the same VirtX code from my laptop to a server?
Yes. Replace Client.spawn() with Client.connect(...) pointing at your own virtx-server-tcp or at VirtX cloud, and keep the rest of the program. A local server removes its sandboxes when your program ends, while your own server or VirtX cloud keeps them.
Which setup is safer for code an AI agent wrote?
Both put the code behind a hypervisor with its own kernel, so the isolation model is the same. The difference lies in what else you configure, such as network rules, credentials and which files the sandbox can see. Start from the strictest setting that still lets the job finish, for example network off and only the files the job needs.
