Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 49 additions & 35 deletions docs/template/base-image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,65 +28,79 @@
**File ignoring**: The SDK automatically reads `.dockerignore` files and combines them with your `fileIgnorePatterns` (TypeScript) or `file_ignore_patterns` (Python). Files matching these patterns are excluded from uploads and hash calculations.

## Defining base image
Choose from predefined base images or use custom ones:

Every template starts with a base image that provides the foundation for your sandbox environment.

### Predefined base images

Use convenience methods for common base images with Ubuntu, Debian, Python, Node.js, or Bun:

<CodeGroup>

```typescript JavaScript & TypeScript
// Predefined base images
template.fromUbuntuImage("jammy"); // ubuntu:jammy
template.fromUbuntuImage("22.04"); // ubuntu:22.04
template.fromDebianImage("stable-slim"); // debian:stable-slim
template.fromDebianImage("bullseye"); // debian:bullseye
template.fromPythonImage("3.13"); // python:3.13
template.fromPythonImage("3.11"); // python:3.11
template.fromNodeImage("lts"); // node:lts
template.fromNodeImage("20"); // node:20
template.fromBunImage("1.3"); // oven/bun:1.3

// Custom base image
template.fromImage("custom-image:latest");

// Use default E2B base image
template.fromBaseImage(); // e2bdev/base

// Parse existing Dockerfile
const dockerfileContent = `
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
ENV NODE_ENV=production`;

template.fromDockerfile(dockerfileContent);
```

```python Python
# Predefined base images
template.from_ubuntu_image("jammy") # ubuntu:jammy
template.from_ubuntu_image("22.04") # ubuntu:22.04
template.from_debian_image("stable-slim") # debian:stable-slim
template.from_debian_image("bullseye") # debian:bullseye
template.from_python_image("3.13") # python:3.13
template.from_python_image("3.11") # python:3.11
template.from_node_image("lts") # node:lts
template.from_node_image("20") # node:20
template.from_bun_image("1.3") # oven/bun:1.3
```

</CodeGroup>

### Custom base image

Use any Docker image from Docker Hub or other registries:

<CodeGroup>

```typescript JavaScript & TypeScript
template.fromImage("custom-image:latest");
```

# Custom base image
```python Python
template.from_image("custom-image:latest")
```

</CodeGroup>

### Default E2B base image

Use the default E2B base image, which comes pre-configured for sandbox environments:

<CodeGroup>

```typescript JavaScript & TypeScript
template.fromBaseImage(); // e2bdev/base
```

# Use default E2B base image
```python Python
template.from_base_image() # e2bdev/base
```

</CodeGroup>

### Build from existing template

Extend an existing template from your team or organization:

<CodeGroup>

```typescript JavaScript & TypeScript
template.fromTemplate("my-template"); // Your team's template
template.fromTemplate("acme/other-template"); // Full namespaced reference
```

# Build from existing template
```python Python
template.from_template("my-template") # Your team's template
template.from_template("acme/other-template") # Full namespaced reference

# Parse and build from Dockerfile
template.from_dockerfile("Dockerfile")
template.from_dockerfile("FROM ubuntu:22.04\nRUN apt-get update")
```

</CodeGroup>
Expand All @@ -95,9 +109,9 @@
You can only call base image methods once per template. Subsequent calls will throw an error.
</Note>

## Parsing existing Dockerfiles

Check warning on line 112 in docs/template/base-image.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/template/base-image.mdx#L112

Did you really mean 'Dockerfiles'?

Convert existing Dockerfiles to template format using `fromDockerfile()`:

Check warning on line 114 in docs/template/base-image.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/template/base-image.mdx#L114

Did you really mean 'Dockerfiles'?

<CodeGroup>

Expand Down Expand Up @@ -136,7 +150,7 @@

</CodeGroup>

### Dockerfile instructions support

Check warning on line 153 in docs/template/base-image.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/template/base-image.mdx#L153

Did you really mean 'Dockerfile'?

| Instruction | Supported | Behavior |
| :--- | :----: | :--- |
Expand Down