Skip to content

Why

Docker Sandboxes runs code, and coding agents, in throw-away microVMs. It is driven by the sbx CLI, which talks to a daemon, sandboxd, through a Unix socket. Without a library, a Python program that wants a sandbox runs the CLI and parses what it prints.

fastsandbox talks to the socket instead, through docker-sandbox, the Rust client of that socket, and its sister crates for kits and sandbox specs, and gives Python two layers on top of them: a typed async client, and FastSandbox, a framework where the work done in a sandbox is a typed function under a decorator.

What that changes for you

  • Typed payloads. Every request and every answer of the daemon is a Pydantic model; an editor completes them and mypy checks them. Fields a newer daemon adds are kept, not dropped.
  • Errors you can match on. A missing sandbox is a NotFoundError, a deadline a SandboxTimeoutError, a failed command a CommandFailedError, each with typed attributes: a handler never reads a message. See Errors.
  • Sandboxes that clean up after themselves. A sandbox created in an async with block is deleted when the block ends, on an error or a cancellation too; a sandbox launched from a spec is removed with its network rules and its keys; a FastSandbox task removes its sandbox when its function returns, raises, times out or is cancelled. Only a killed process or a failed removal leaves one behind: see Sandbox lifecycle.
  • Work declared, not scripted. @app.task and @app.agent state the kit, the network rules, the deadline and the credentials of a sandbox next to the function that uses it; the signature validates the inputs and the result. See FastSandbox.
  • Keys scoped to one sandbox. The API key of an agent goes to the proxy of the sandbox of the run only, which writes it into the requests to its service; the agent sees a placeholder, which it can still use to call that service while the sandbox lives. Kiro is the exception. See Credentials.
  • Tests without a daemon. A fake daemon serves the socket API in memory, so the code that drives sandboxes is tested in any CI. See Testing.

What it is not

fastsandbox is not a product of Docker, Inc., and not a replacement for sbx: Docker Sandboxes must be installed on the machine, its daemon running, since fastsandbox connects to its socket and forges the kits through it. It is not a sandbox runtime either: the isolation is that of Docker Sandboxes, and fastsandbox decides only what crosses it (see Security). Nor is it a client of the Docker Engine: containers and images outside Docker Sandboxes belong to the Docker SDK.

See the features Quickstart