Skip to main content
Agents with runtime.command (code runtime) or loop config (managed loop) run in E2B sandboxes. The platform automatically selects the right base image based on your agent’s entrypoint: JavaScript agents get a dedicated Node.js sandbox template with both Node.js and Python pre-installed. Dependencies from package.json are installed automatically via npm ci (when a lockfile is present) or npm install. Custom environments let you add dependencies beyond the defaults.

Predefined Environments

Four ready-to-use environments are available to all users:

Set as Workspace Default

All agents in your workspace can use a default environment: Via CLI:
Via Web UI: Settings → Workspace → Default Environment Agents without their own Dockerfile use this default.

Custom Environments

Need specific packages? Include a Dockerfile in your agent directory.

Quick Start

Publish with the --docker flag:
The platform builds your custom environment. First build takes 2-5 minutes; subsequent publishes with the same Dockerfile reuse the cached build.
You don’t need Docker installed locally. The platform handles all building.

Dockerfile Guidelines

Base image (required):
What works:
What doesn’t work:
COPY and ADD commands are rejected because Dockerfiles are built in isolation without access to your bundle files. Install dependencies via pip/apt instead, or download files at runtime in your agent code.

Example: Video Processing Agent

Prefer pip install over apt-get when possible. Many system packages (like ffmpeg) have pure-Python alternatives (like imageio-ffmpeg) that work better in cloud sandboxes.

CLI Commands

Environment Priority

When running an agent in a sandbox:
  1. Agent-specific — Dockerfile in bundle creates dedicated environment
  2. Workspace default — Falls back to workspace’s default environment
  3. Base image — Uses E2B’s base code-interpreter if neither set
Dynamic workspace defaults: Changing your workspace default immediately affects all agents that don’t have their own Dockerfile. Existing agents without agent-specific environments will use the new default on their next run.

Service Environments

Always-on services use a different runtime from on-demand runs: Service dependencies are installed from your requirements.txt or package.json during deployment. The service runner pre-installs common tools (pip, npm, git).
Custom Dockerfiles are not yet supported for services. If your service needs system packages beyond the defaults, use a run_command in your manifest that installs them at startup.