Sandboxes With Your Toolchain
A Linux microVM (4 vCPU, 16 GB RAM) with the packages you list: Python, Node.js, Go, Bun and more.
You’re root in /work. Sandboxes →
Go · Python · TypeScript · Rust
Create a sandbox on Chainguard Workspaces, run commands in it, move files in and out, and delete it. It's the same workflow as Vercel Sandbox, E2B or Modal, in Go, Python, TypeScript and Rust.
with Sandbox.create( packages=["bash", "coreutils", "python-3.13"], # instance="XXXXXX", # your organization ID; overrides $CHAINCTL_SANDBOX_INSTANCE and auto-detection) as sbx: # deleted on exit result = sbx.commands.run("""python3 -c "print('hello from', __import__('platform').node())" """) print(result.stdout, end="")
sbx.files.write("notes/hello.txt", "hi") print(sbx.files.read("notes/hello.txt"))await using sbx = await Sandbox.create({ packages: ["bash", "coreutils", "python-3.13"], // instance: "XXXXXX", // your organization ID; overrides $CHAINCTL_SANDBOX_INSTANCE and auto-detection}); // deleted at the end of the block
const result = await sbx.commands.run(`python3 -c "print('hello from', __import__('platform').node())"`);console.log(result.stdout.trimEnd());
await sbx.files.write("notes/hello.txt", "hi");console.log(await sbx.files.read("notes/hello.txt"));func main() { // log.Fatal exits without running deferred calls, so the work is in run: // its deferred Kill has already deleted the sandbox when an error gets here. if err := run(context.Background()); err != nil { log.Fatal(err) }}
func run(ctx context.Context) error { sb, err := sandbox.Create(ctx, &sandbox.CreateOptions{ Packages: []string{"bash", "coreutils", "python-3.13"}, // Instance: "XXXXXX", // your organization ID; overrides $CHAINCTL_SANDBOX_INSTANCE and auto-detection }) if err != nil { return err } defer sb.Kill(context.Background()) // delete the sandbox when done, on success and on error
res, err := sb.Commands.Run(ctx, `python3 -c "print('hello from', __import__('platform').node())"`, nil) if err != nil { return err } fmt.Print(res.Stdout)
if _, err := sb.Files.Write(ctx, "notes/hello.txt", []byte("hi")); err != nil { return err } text, err := sb.Files.ReadText(ctx, "notes/hello.txt") if err != nil { return err } fmt.Println(text) return nil}let opts = CreateOptions { packages: Some(vec![ "bash".into(), "coreutils".into(), "python-3.13".into(), ]), // instance: "XXXXXX".into(), // your organization ID; overrides $CHAINCTL_SANDBOX_INSTANCE and auto-detection ..Default::default()};// The sandbox is deleted when the closure returns, on success and on error.Sandbox::with(opts, async |sbx| { let res = sbx .commands .run(r#"python3 -c "print('hello from', __import__('platform').node())""#) .await?; print!("{}", res.stdout);
sbx.files.write("notes/hello.txt", "hi").await?; println!("{}", sbx.files.read_text("notes/hello.txt").await?); Ok(())}).await| Language | Import | In chainguard-sandbox-sdk |
|---|---|---|
| Go | github.com/sandboxing-dev/chainguard-sandbox-sdk/go/sandbox |
go/ |
| Python | from chainguard_sandbox import Sandbox |
python/ (distribution chainguard-sandbox-sdk) |
| TypeScript (Node.js, Bun) | import { Sandbox } from "chainguard-sandbox-sdk" |
typescript/ |
| Rust | use chainguard_sandbox::Sandbox; |
rust/ (crate chainguard-sandbox-sdk) |
Sandboxes With Your Toolchain
A Linux microVM (4 vCPU, 16 GB RAM) with the packages you list: Python, Node.js, Go, Bun and more.
You’re root in /work. Sandboxes →
Commands
Shell strings or argv, with cwd, env, stdin, timeouts and live output. Background commands give
you a handle to wait, poll and kill. Commands →
Files
Read, write (batched, any size), list, stat, move and remove. Upload and download files and whole directories. Files →
Network Control
An egress allowlist that is enforced (verified), on top of an always-on block of cloud metadata, loopback and private ranges. Environments →
Pause and Resume
A paused sandbox is a memory and disk snapshot; its processes continue on the next call. Lifecycle →
Login and Organization
A browser login once, saved and refreshed. Your organization is detected automatically when you have one. Authentication →
Workspaces is built for long-lived developer sessions, not for spinning up thousands of short-lived sandboxes. The main constraints:
Limits and differences has the full list, and Coming from Vercel, E2B or Modal maps their APIs to this one.