> ## Documentation Index
> Fetch the complete documentation index at: https://e2b.manicule.dev/v2.1.5/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://e2b.manicule.dev/v2.1.5/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://e2b.manicule.dev/api/mcp.
> Every agent surface: https://e2b.manicule.dev/.well-known/llms-manifest.json

# Template (/v2.1.5/template)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 1012 · updated: 2026-07-30 -->
Related: [Exceptions](/v2.1.5/exceptions.md), [Readycmd](/v2.1.5/readycmd.md), [Sandbox Async](/v2.1.5/sandbox_async.md), [Sandbox Sync](/v2.1.5/sandbox_sync.md)

### BASE_STEP_NAME

Depths explained:

1. TemplateClass
2. Caller method (eg. copy(), fromImage(), etc.)

## BuildException

```python
class BuildException(Exception)
```

Raised when a build fails.

## FileUploadException

```python
class FileUploadException(BuildException)
```

Raised when a file upload fails.

### strip_ansi_escape_codes

```python
def strip_ansi_escape_codes(text: str) -> str
```

Strip ANSI escape codes from a string. Source: [https://github.com/chalk/ansi-regex/blob/main/index.js](https://github.com/chalk/ansi-regex/blob/main/index.js)

### get_caller_frame

```python
def get_caller_frame(depth: int) -> Optional[FrameType]
```

Get the caller frame. Skip this function (first frame).

### get_caller_directory

```python
def get_caller_directory(depth: int) -> Optional[str]
```

Get the directory of the file that called this function.

## DockerfFileFinalParserInterface

```python
class DockerfFileFinalParserInterface(Protocol)
```

Protocol defining the final interface for Dockerfile parsing callbacks.

## DockerfileParserInterface

```python
class DockerfileParserInterface(Protocol)
```

Protocol defining the interface for Dockerfile parsing callbacks.

### run_cmd

```python
def run_cmd(command: Union[str, List[str]],
            user: Optional[str] = None) -> "DockerfileParserInterface"
```

Handle RUN instruction.

### copy

```python
def copy(src: Union[str, List[CopyItem]],
         dest: Optional[str] = None,
         force_upload: Optional[bool] = None,
         user: Optional[str] = None,
         mode: Optional[int] = None) -> "DockerfileParserInterface"
```

Handle COPY instruction.

### set_workdir

```python
def set_workdir(workdir: str) -> "DockerfileParserInterface"
```

Handle WORKDIR instruction.

### set_user

```python
def set_user(user: str) -> "DockerfileParserInterface"
```

Handle USER instruction.

### set_envs

```python
def set_envs(envs: Dict[str, str]) -> "DockerfileParserInterface"
```

Handle ENV instruction.

### set_start_cmd

```python
def set_start_cmd(start_cmd: str,
                  ready_cmd: str) -> "DockerfFileFinalParserInterface"
```

Handle CMD/ENTRYPOINT instruction.

### parse_dockerfile

```python
def parse_dockerfile(dockerfile_content_or_path: str,
                     template_builder: DockerfileParserInterface) -> str
```

Parse a Dockerfile and convert it to Template SDK format.

**Arguments**:

* `dockerfile_content_or_path` - Either the Dockerfile content as a string,
  or a path to a Dockerfile file
* `template_builder` - Interface providing template builder methods

**Returns**:

The base image from the Dockerfile

**Raises**:

* `ValueError` - If the Dockerfile is invalid or unsupported

### wait_for_port

```python
def wait_for_port(port: int)
```

Generate a command to wait for a port to be available.

### wait_for_url

```python
def wait_for_url(url: str, status_code: int = 200)
```

Generate a command to wait for a URL to return a specific status code.

### wait_for_process

```python
def wait_for_process(process_name: str)
```

Generate a command to wait for a process to be running.

### wait_for_file

```python
def wait_for_file(filename: str)
```

Generate a command to wait for a file to exist.

### wait_for_timeout

```python
def wait_for_timeout(timeout: int)
```

Generate a command to wait for a specified duration.

## TemplateBase

```python
class TemplateBase()
```

### skip_cache

```python
def skip_cache() -> "TemplateBase"
```

Skip cache for the next instruction (before from instruction)

### from_image

```python
def from_image(
        base_image: str,
        registry_config: Optional[RegistryConfig] = None) -> TemplateBuilder
```

Private method to set base image without adding stack trace

### from_dockerfile

```python
def from_dockerfile(dockerfile_content_or_path: str) -> TemplateBuilder
```

Parse a Dockerfile and convert it to Template SDK format

**Arguments**:

* `dockerfile_content_or_path` - Either the Dockerfile content as a string,
  or a path to a Dockerfile file
