Firecracker Sandbox
Firecracker sandboxes run inside lightweight virtual machines instead of containers. Each sandbox boots its own Linux kernel in under 100ms and is completely isolated from the host and from other sandboxes at the hardware level. There is no shared kernel - a vulnerability in one sandbox cannot affect another.
Use Firecracker when:
- You are running untrusted or LLM-generated code that should not have any path to the host kernel
- Your workload requires VM-level security boundaries (compliance, multi-tenant execution)
- You want faster cold starts than full VMs while keeping stronger isolation than containers
Create a Firecracker sandbox
Section titled “Create a Firecracker sandbox”Pass runtime: "firecracker" and an OCI image reference. The daemon pulls the image and builds a Firecracker-compatible rootfs from it. Public exposure is opt-in — exposePort flips the sandbox public on first use, or set allowPublicTraffic: true at create for a boot-time public URL; see Network Isolation.
import { MicroVM } from '@aerol-ai/aerolvm-sdk'
const client = new MicroVM({ apiUrl: process.env.SB_API_URL, patToken: process.env.SB_PAT_TOKEN,})
const sandbox = await client.create({ image: 'ubuntu:22.04', runtime: 'firecracker', cpu: 1, memoryMB: 512,})
console.log(sandbox.id)from microvm import MicroVM
client = MicroVM( api_url='https://sandbox.example.com', pat_token='your-token',)
sandbox = client.create({ 'image': 'ubuntu:22.04', 'runtime': 'firecracker', 'cpu': 1.0, 'memoryMB': 512,})
print(sandbox.id)import ( "context" "fmt" "log" "os"
microvm "github.com/aerol-ai/microvm/sdk/go/pkg/microvm" sdktypes "github.com/aerol-ai/microvm/sdk/go/pkg/types")
client, err := microvm.NewClientWithConfig(&sdktypes.MicroVMConfig{ APIUrl: os.Getenv("SB_API_URL"), PATToken: os.Getenv("SB_PAT_TOKEN"),})if err != nil { log.Fatal(err)}
sandbox, err := client.Create(context.Background(), sdktypes.CreateSandboxOptions{ Image: "ubuntu:22.04", Runtime: sdktypes.RuntimeFirecracker, CPU: 1, MemoryMB: 512,})if err != nil { log.Fatal(err)}
fmt.Println(sandbox.ID)use aerolvm_sdk::{Client, CreateOptions};
let client = Client::new( Some("https://sandbox.example.com"), Some("your-token"),)?;
let sandbox = client.create(CreateOptions { image: "ubuntu:22.04".to_string(), runtime: Some("firecracker".to_string()), cpu: Some(1), memory_mb: Some(512), ..Default::default()})?;
println!("{}", sandbox.data.id);import ai.aerol.microvm.MicroVMClient;import ai.aerol.microvm.MicroVMConfig;import ai.aerol.microvm.Sandbox;import ai.aerol.microvm.model.CreateOptions;
MicroVMClient client = new MicroVMClient( new MicroVMConfig() .setApiUrl("https://sandbox.example.com") .setPatToken(System.getenv("SB_PAT_TOKEN")));
Sandbox sandbox = client.create( new CreateOptions() .setImage("ubuntu:22.04") .setRuntime("firecracker") .setCpu(1.0) .setMemoryMb(512));
System.out.println(sandbox.id);With lifecycle
Section titled “With lifecycle”const sandbox = await client.create({ image: 'ubuntu:22.04', runtime: 'firecracker', cpu: 2, memoryMB: 1024, lifecycle: { stopIfIdleFor: 30 * 60 * 1_000_000_000, // 30 minutes destroyAtAge: 4 * 60 * 60 * 1_000_000_000, // 4 hours },})sandbox = client.create({ 'image': 'ubuntu:22.04', 'runtime': 'firecracker', 'cpu': 2.0, 'memoryMB': 1024, 'lifecycle': { 'stopIfIdleFor': 1_800_000_000_000, # 30 minutes 'destroyAtAge': 14_400_000_000_000, # 4 hours },})sandbox, err := client.Create(ctx, sdktypes.CreateSandboxOptions{ Image: "ubuntu:22.04", Runtime: sdktypes.RuntimeFirecracker, CPU: 2, MemoryMB: 1024, Lifecycle: &sdktypes.Lifecycle{ StopIfIdleFor: 30 * time.Minute, DestroyAtAge: 4 * time.Hour, },})let sandbox = client.create(CreateOptions { image: "ubuntu:22.04".to_string(), runtime: Some("firecracker".to_string()), cpu: Some(2), memory_mb: Some(1024), lifecycle: Some(aerolvm_sdk::Lifecycle { stop_if_idle_for: 1_800_000_000_000, destroy_at_age: 14_400_000_000_000, ..Default::default() }), ..Default::default()})?;Sandbox sandbox = client.create( new CreateOptions() .setImage("ubuntu:22.04") .setRuntime("firecracker") .setCpu(2.0) .setMemoryMb(1024) .setLifecycle(new Lifecycle() .setStopIfIdleFor(1_800_000_000_000L) .setDestroyAtAge(14_400_000_000_000L)));- Ad-hoc builds every time. Without a pre-built template, each create runs the full OCI-to-rootfs pipeline - expect 10–60 seconds per create. For sub-100ms boots, pre-build a template with Firecracker Templates and pass
template_idin the create request (Go SDK exposes this asTemplateID; other SDKs use the direct API). - Memory is reserved. Unlike Docker, Firecracker allocates the full
memoryMBvalue upfront for the VM. Size the request to what the workload actually needs. - Not compatible with GPU passthrough. Firecracker VMs do not support direct GPU access.
- Lifecycle operations (stop, start, destroy, resize) work the same as Docker sandboxes. See Docker Sandbox for those examples.