E2B

E2B Firecracker micro-VMs, pause/resume, fork, and persistent volumes.

Core concepts

  1. Firecracker-based micro-VMs: Genuine, strong isolation per sandbox, not just a container namespace. E2B Docs
  2. Pause, resume, and fork: Pause a sandbox (saving filesystem and memory state), resume it in about a second, or fork new sandboxes from a named snapshot of a running one.
  3. Persistent volumes: Mount storage that outlives any single sandbox's lifetime, separate from the pause/resume mechanism.

What Is It?

E2B uses Firecracker micro-VMs for strong isolation with low startup time.

Supports pausing sessions, forking state, and attaching persistent volumes.

Popular SDK for Python/JS agent runtimes.

Why Should I Care?

Strong isolation story for CodeAgent patterns and user-supplied code.

Pause/resume saves money between long human think times.

Real World Analogy

E2B Firecracker micro-VMs are disposable kitchen pods — spin up, cook agent code, hose down, next customer.

Visual Mental Model

text
Firecracker VM
  pause / resume / fork
  persistent volume optional

Beginner Explanation

E2B offers fast micro-VMs with pause/resume and fork — great for code interpreters and multi-step agent sessions.

Smallest Possible Example

python
# from e2b import Sandbox
# sb = Sandbox.create(); sb.run_code("print(1)")

Common Mistakes

❌ Leaving sandboxes running overnight.

Idle VMs still cost — pause or destroy.

❌ Mounting sensitive host paths into VMs.

Defeats isolation purpose entirely.

❌ No logging of commands executed in sandbox.

Security reviews need audit trails.

Real Project Example

Agent IDEs and OpenAI code interpreter-style products use E2B-class isolation.

Startups embed E2B for 'run Python' buttons in SaaS.

Build This Mini Project

Read E2B quickstart, run hello world sandbox, and document destroy vs pause in your notes.

Interview Question

What is Firecracker's role in E2B?

Firecracker provides lightweight micro-VM isolation per sandbox — stronger than containers alone for untrusted code with fast boot.

Key Takeaways

  • Micro-VM isolation per session.
  • Pause/resume for cost control.
  • Audit commands run inside.
  • Destroy sandboxes when done.

Resources

YouTube learning

Core concepts from video walkthroughs:

The 60-second story

A container is a curtain between hotel rooms. A determined guest can sometimes find the gap. E2B’s pitch is a thicker wall: a micro-VM, Firecracker, a small machine of their own rather than a curtain on a shared kernel story. You pay for that wall because the guest is a model with a shell, not a coworker having a bad day.

Pause, resume, and fork are the front-desk tricks. Pause saves the room, filesystem and memory, so you are not rebuilding the world for every step. Resume is walking back in quickly. Fork is copying a named snapshot into a new room so ten experiments can start from the same half-done setup. That is powerful and also how a secret in the snapshot becomes ten secrets. Snapshot what you mean to copy.

Persistent volumes are the hall locker again, separate from pause. Pause remembers the room. A volume remembers a disk you mount on purpose. If you only pause, a destroyed sandbox can take the work with it. If you only use a volume, you do not get the “come back in a second” trick. They solve different goodbyes.

Map the front desk.

  • Firecracker is the thicker wall, a tiny VM.
  • Pause saves the room.
  • Resume opens it again.
  • Fork copies a snapshot into new rooms.
  • A volume is a disk that outlives the room.
  • A secret in a snapshot is a secret you replicated.
text
start sandbox
do work
snapshot or mount a volume if the artifact must live
destroy the room

The order matters. Destroy is the default ending, not a failure.

E2B exists because agent companies needed isolation stronger than “please do not escape the container,” plus a way to continue work without a cold boot every time. The features are real. The discipline is still yours: do not fork a room that has production credentials sitting in an env file because it was convenient during the demo.

Mental model: a tiny machine you can freeze, copy, and throw away. The wall is the product. The snapshot is a tool. Copying a messy room copies the mess.

You can explain the page if you separate pause (the room) from a volume (the disk), and if fork makes you ask “what did I just duplicate?” Freeze a room when you want to walk back in. Copy it only after you know the secrets are not sitting on the desk.

Threads in the same domain as this chapter — go deeper on iHateReading without leaving the roadmap.

Companies building AI agent sandbox SDKs and APIs cover

Companies building AI agent sandbox SDKs and APIs

Landscape of hosted sandboxes and permission gates for agent code execution.

The whole fight for AI sandbox cover

The whole fight for AI sandbox

Why execution boundaries matter before you give agents shell or browser access.

Agent harnessing: the part of building AI agents nobody talks about cover

Agent harnessing: the part of building AI agents nobody talks about

Loop, tools, memory, sandbox, and tracing live in your code — not the model weights.