> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenfactory.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dockerfile builders

See [Build a Docker image](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/building-images.md) for setup, supported instructions, and differences
from Docker. See [Advanced usage](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/advanced.md) for callbacks, cache lifetimes, and manual assembly. See [Customize the SDK](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/customization.md) for parser and factory hooks.

Dockerfile parser and keyword interpreters.

Each Dockerfile directive is a DockerKeyword subclass living in its own
module. parse\_dockerfile returns a list of directives ready to be executed
against a BuildContext/AsyncBuildContext.

## `class AddKeyword`

```python theme={null}
class contree_sdk.docker.AddKeyword(sources, dest, chown, chmod, from_stage)
```

### Attributes

**NAME** `ClassVar[str]`

**chmod** `str`

**chown** `str`

**dest** `str`

**from\_stage** `str`

**sources** `tuple[str, ...]`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> AddKeyword
```

**args\_text** *required*

**returns** `AddKeyword`

[`AddKeyword`](./docker#contree_sdk.docker.AddKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class ArgKeyword`

```python theme={null}
class contree_sdk.docker.ArgKeyword(name, default)
```

### Attributes

**NAME** `ClassVar[str]`

**default** `str | None`

**name** `str`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> ArgKeyword
```

**args\_text** *required*

**returns** `ArgKeyword`

[`ArgKeyword`](./docker#contree_sdk.docker.ArgKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class AsyncBuildContext`

```python theme={null}
class contree_sdk.docker.AsyncBuildContext(client, store, local, http_fetch_async, session_factory, directive_executor, session_id, session, build_args, declared_args, arg_defaults, env, workdir, user, parent_hash, stages, stage_images, current_stage_alias, pending, no_cache, timeout, last_cache_hit, on_event, progress, upload_cache_ttl, upload_concurrency)
```

### Attributes

**current\_stage\_alias** `str`

**directive\_executor** `Callable[[DockerKeyword, AsyncBuildContext], Awaitable[None]] | None`

Callable\[\[[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword), [`AsyncBuildContext`](./docker#contree_sdk.docker.AsyncBuildContext)], Awaitable\[None]] | None

**file\_sources** `AsyncFileSources`

[`AsyncFileSources`](./cache#contree_sdk.file_sources.AsyncFileSources)

**last\_cache\_hit** `bool`

**last\_image** `str`

**no\_cache** `bool`

**on\_event** `Callable[[BuildEvent], object] | None`

Callable\[\[[`BuildEvent`](./docker#contree_sdk.docker.BuildEvent)], object] | None

**parent\_hash** `str`

**session** `ContreeAsyncSession | None`

[`ContreeAsyncSession`](./session#contree_sdk.session.ContreeAsyncSession) | None

**session\_factory**

alias of [`ContreeAsyncSession`](./session#contree_sdk.session.ContreeAsyncSession)

**session\_id** `str`

**timeout** `int`

**upload\_cache\_ttl** `float`

**upload\_concurrency** `int`

**user** `str`

**workdir** `str`

**client** `ContreeAsyncClient`

**store** `AsyncStore`

[`AsyncStore`](./store#contree_sdk.store.AsyncStore)

**local** `LocalContext`

[`LocalContext`](./docker#contree_sdk.docker.LocalContext)

**build\_args** `dict[str, str]`

**declared\_args** `set[str]`

**arg\_defaults** `dict[str, str]`

**env** `dict[str, str]`

**stages** `dict[str, str]`

**stage\_images** `list[str]`

**pending** `list[PendingFile]`

list\[[`PendingFile`](./docker#contree_sdk.docker.PendingFile)]

**progress** `BuildProgress`

### Methods

#### `arg_values()`

```python theme={null}
def arg_values() -> dict[str, str]
```

**returns** `dict[str, str]`

#### `cache_namespace()`

```python theme={null}
def cache_namespace(namespace) -> str
```

**namespace** *required*

**returns** `str`

#### `chain()`

```python theme={null}
def chain(contribution) -> str
```

**contribution** *required*

**returns** `str`

#### `commit_layer()`

```python theme={null}
async def commit_layer(branch_name, image_uuid, *, kind, title, operation_uuid) -> None
```

**branch\_name** *required*

**image\_uuid** *required*

**kind** *required*

**title** *required*

**operation\_uuid** (default: '')

**returns** `None`

#### `create_session()`

```python theme={null}
def create_session(client, *, session_id, store, image, node_id) -> ContreeAsyncSession
```

Return a session from the configured factory.

**client** *required*

**session\_id** *required*

**store** *required*

**image** *required*

**node\_id** (default: None)

**returns** `ContreeAsyncSession`

[`ContreeAsyncSession`](./session#contree_sdk.session.ContreeAsyncSession)

The configured session implementation.

#### `emit_event()`

```python theme={null}
async def emit_event(event_type, *, data, error) -> None
```

Deliver one notification through the configured build callback.

**event\_type** *required*

**data** (default: b'')

**error** (default: None)

**returns** `None`

#### `execute_directive()`

```python theme={null}
async def execute_directive(directive) -> None
```

Run a nested directive through the builder’s policy when configured.

**directive** *required*

**returns** `None`

#### `http_fetch_async()`

```python theme={null}
async def http_fetch_async(method, headers) -> tuple[int, Iterable[tuple[str, str]], AsyncIterable[bytes]]
```

**method** *required*

**headers** *required*

**returns** `tuple[int, Iterable[tuple[str, str]], AsyncIterable[bytes]]`

#### `pending_files_payload()`

```python theme={null}
def pending_files_payload() -> dict[str, str | Path | bytes | UploadFileSpec]
```

**returns** `dict[str, str | Path | bytes | UploadFileSpec]`

dict\[str, str | Path | bytes | [`UploadFileSpec`](./files#contree_sdk.files.UploadFileSpec)]

#### `pending_repr()`

```python theme={null}
def pending_repr() -> str
```

**returns** `str`

#### `run_operation()`

```python theme={null}
async def run_operation(request, *, branch) -> InstanceResult
```

Stream and commit one RUN operation through the session’s public lifecycle.

**request** *required*

**branch** *required*

**returns** `InstanceResult`

The terminal process result, including nonzero exits.

**raises**

[**DockerBuildError**](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/reference/exceptions.md#contree_sdk.exceptions.DockerBuildError) – No FROM session is active.

#### `state_repr()`

```python theme={null}
def state_repr() -> str
```

**returns** `str`

#### `substitute()`

```python theme={null}
def substitute(text) -> str
```

**text** *required*

**returns** `str`

#### `try_cache_hit()`

```python theme={null}
async def try_cache_hit(branch_name, *, kind) -> str | None
```

**branch\_name** *required*

**kind** (default: 'run')

**returns** `str | None`

## `class BuildContext`

```python theme={null}
class contree_sdk.docker.BuildContext(client, store, local, http_fetch, session_factory, directive_executor, session_id, session, build_args, declared_args, arg_defaults, env, workdir, user, parent_hash, stages, stage_images, current_stage_alias, pending, no_cache, timeout, last_cache_hit, on_event, progress, upload_cache_ttl, upload_concurrency)
```

### Attributes

**current\_stage\_alias** `str`

**directive\_executor** `Callable[[DockerKeyword, BuildContext], None] | None`

Callable\[\[[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword), [`BuildContext`](./docker#contree_sdk.docker.BuildContext)], None] | None

**file\_sources** `SyncFileSources`

[`SyncFileSources`](./cache#contree_sdk.file_sources.SyncFileSources)

**last\_cache\_hit** `bool`

**last\_image** `str`

**no\_cache** `bool`

**on\_event** `Callable[[BuildEvent], None] | None`

Callable\[\[[`BuildEvent`](./docker#contree_sdk.docker.BuildEvent)], None] | None

**parent\_hash** `str`

**session** `ContreeSession | None`

[`ContreeSession`](./session#contree_sdk.session.ContreeSession) | None

**session\_factory**

alias of [`ContreeSession`](./session#contree_sdk.session.ContreeSession)

**session\_id** `str`

**timeout** `int`

**upload\_cache\_ttl** `float`

**upload\_concurrency** `int`

**user** `str`

**workdir** `str`

**client** `ContreeSyncClient`

**store** `SyncStore`

[`SyncStore`](./store#contree_sdk.store.SyncStore)

**local** `LocalContext`

[`LocalContext`](./docker#contree_sdk.docker.LocalContext)

**build\_args** `dict[str, str]`

**declared\_args** `set[str]`

**arg\_defaults** `dict[str, str]`

**env** `dict[str, str]`

**stages** `dict[str, str]`

**stage\_images** `list[str]`

**pending** `list[PendingFile]`

list\[[`PendingFile`](./docker#contree_sdk.docker.PendingFile)]

**progress** `BuildProgress`

### Methods

#### `arg_values()`

```python theme={null}
def arg_values() -> dict[str, str]
```

**returns** `dict[str, str]`

#### `cache_namespace()`

```python theme={null}
def cache_namespace(namespace) -> str
```

**namespace** *required*

**returns** `str`

#### `chain()`

```python theme={null}
def chain(contribution) -> str
```

**contribution** *required*

**returns** `str`

#### `commit_layer()`

```python theme={null}
def commit_layer(branch_name, image_uuid, *, kind, title, operation_uuid) -> None
```

**branch\_name** *required*

**image\_uuid** *required*

**kind** *required*

**title** *required*

**operation\_uuid** (default: '')

**returns** `None`

#### `create_session()`

```python theme={null}
def create_session(client, *, session_id, store, image, node_id) -> ContreeSession
```

Return a session from the configured factory.

**client** *required*

**session\_id** *required*

**store** *required*

**image** *required*

**node\_id** (default: None)

**returns** `ContreeSession`

[`ContreeSession`](./session#contree_sdk.session.ContreeSession)

The configured session implementation.

#### `emit_event()`

```python theme={null}
def emit_event(event_type, *, data, error) -> None
```

Deliver one notification through the configured build callback.

**event\_type** *required*

**data** (default: b'')

**error** (default: None)

**returns** `None`

#### `execute_directive()`

```python theme={null}
def execute_directive(directive) -> None
```

Run a nested directive through the builder’s policy when configured.

**directive** *required*

**returns** `None`

#### `http_fetch()`

```python theme={null}
def http_fetch(method, headers) -> tuple[int, Iterable[tuple[str, str]], Iterable[bytes]]
```

**method** *required*

**headers** *required*

**returns** `tuple[int, Iterable[tuple[str, str]], Iterable[bytes]]`

#### `pending_files_payload()`

```python theme={null}
def pending_files_payload() -> dict[str, str | Path | bytes | UploadFileSpec]
```

**returns** `dict[str, str | Path | bytes | UploadFileSpec]`

dict\[str, str | Path | bytes | [`UploadFileSpec`](./files#contree_sdk.files.UploadFileSpec)]

#### `pending_repr()`

```python theme={null}
def pending_repr() -> str
```

**returns** `str`

#### `run_operation()`

```python theme={null}
def run_operation(request, *, branch) -> InstanceResult
```

Stream and commit one RUN operation through the session’s public lifecycle.

**request** *required*

**branch** *required*

**returns** `InstanceResult`

The terminal process result, including nonzero exits.

**raises**

[**DockerBuildError**](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/reference/exceptions.md#contree_sdk.exceptions.DockerBuildError) – No FROM session is active.

#### `state_repr()`

```python theme={null}
def state_repr() -> str
```

**returns** `str`

#### `substitute()`

```python theme={null}
def substitute(text) -> str
```

**text** *required*

**returns** `str`

#### `try_cache_hit()`

```python theme={null}
def try_cache_hit(branch_name, *, kind) -> str | None
```

**branch\_name** *required*

**kind** (default: 'run')

**returns** `str | None`

## `class BuildEvent`

```python theme={null}
class contree_sdk.docker.BuildEvent(*, type, step, operation_uuid, image_before, image_after, duration, data, result, error)
```

A build notification with raw output bytes and the current operation identity.

result is available after the operation finishes, including nonzero exits.
Errors retain their original exception object. Output is never decoded or formatted.

### Attributes

**data** `bytes`

**duration** `float`

**error** `BaseException | None`

**image\_after** `str | None`

**image\_before** `str | None`

**operation\_uuid** `str | None`

**result** `InstanceResult | None`

**type** `Literal['step_started', 'operation_started', 'stdout', 'stderr', 'cache_hit', 'step_completed', 'step_failed']`

**step** `BuildStep`

[`BuildStep`](./docker#contree_sdk.docker.BuildStep)

## `class BuildRequest`

```python theme={null}
class contree_sdk.docker.BuildRequest(*, context_dir, dockerfile_path, session_id, build_args, no_cache, timeout)
```

Resolved local inputs and options for one build context.

### Attributes

**no\_cache** `bool`

**timeout** `int`

**context\_dir** `Path`

**dockerfile\_path** `Path`

**session\_id** `str`

**build\_args** `dict[str, str]`

## `class BuildStep`

```python theme={null}
class contree_sdk.docker.BuildStep(id, keyword, index, parent_id)
```

One directive execution; IDs start at zero within each build.

index is the parsed Dockerfile position, or None for a synthetic step.
parent\_id identifies the enclosing directive for nested execution.

### Attributes

**index** `int | None`

**parent\_id** `int | None`

**id** `int`

**keyword** `str`

## `class BuildStepEvent`

```python theme={null}
class contree_sdk.docker.BuildStepEvent(index, keyword, cache_hit, image_before, image_after, duration, error)
```

Reported to on\_step around each directive’s execute()/execute\_async() call.

### Attributes

**error** `BaseException | None`

**index** `int`

**keyword** `str`

**cache\_hit** `bool`

**image\_before** `str | None`

**image\_after** `str | None`

**duration** `float`

## `class ContreeAsyncDockerBuilder`

```python theme={null}
class contree_sdk.docker.ContreeAsyncDockerBuilder(client, *, store, http_fetch_async, parser, session_factory)
```

Build a Dockerfile from context.

Applies each directive against a content-addressed layer cache keyed by
the build’s session.

### Attributes

**context\_class**

alias of [`AsyncBuildContext`](#contree_sdk.docker.AsyncBuildContext)

**session** `ContreeAsyncSession | None`

[`ContreeAsyncSession`](./session#contree_sdk.session.ContreeAsyncSession) | None

### Methods

#### `build()`

```python theme={null}
async def build(context, *, dockerfile, tag, build_args, no_cache, timeout, session_id, on_event, on_step) -> str
```

**context** *required*

**dockerfile** (default: None)

**tag** (default: None)

**build\_args** (default: None)

**no\_cache** (default: False)

**timeout** (default: 600)

**session\_id** (default: None)

**on\_event** (default: None)

**on\_step** (default: None)

**returns** `str`

#### `create_context()`

```python theme={null}
async def create_context(request) -> AsyncBuildContext
```

Construct per-build state using the public context and session factories.

**request** *required*

**returns** `AsyncBuildContext`

[`AsyncBuildContext`](./docker#contree_sdk.docker.AsyncBuildContext)

A context owned by this build invocation.

#### `execute_directive()`

```python theme={null}
async def execute_directive(directive, context) -> None
```

Execute one directive. Override for policy checks or instrumentation.

**directive** *required*

**context** *required*

**returns** `None`

#### `finalize()`

```python theme={null}
async def finalize(context) -> None
```

Commit pending file attachments through the same directive execution hook.

**context** *required*

**returns** `None`

#### `parse()`

```python theme={null}
def parse(text) -> list[DockerKeyword]
```

Return build directives through the configured parser.

**text** *required*

**returns** `list[DockerKeyword]`

list\[[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword)]

The parsed directives in source order.

#### `run_step()`

```python theme={null}
async def run_step(directive, context, *, index) -> None
```

Report one directive execution, including nested and synthetic steps.

**directive** *required*

**context** *required*

**index** (default: None)

**returns** `None`

## `class ContreeDockerBuilder`

```python theme={null}
class contree_sdk.docker.ContreeDockerBuilder(client, *, store, http_fetch, parser, session_factory)
```

Build a Dockerfile from context.

Applies each directive against a content-addressed layer cache keyed by
the build’s session.

### Attributes

**context\_class**

alias of [`BuildContext`](#contree_sdk.docker.BuildContext)

**session** `ContreeSession | None`

[`ContreeSession`](./session#contree_sdk.session.ContreeSession) | None

### Methods

#### `build()`

```python theme={null}
def build(context, *, dockerfile, tag, build_args, no_cache, timeout, session_id, on_event, on_step) -> str
```

**context** *required*

**dockerfile** (default: None)

**tag** (default: None)

**build\_args** (default: None)

**no\_cache** (default: False)

**timeout** (default: 600)

**session\_id** (default: None)

**on\_event** (default: None)

**on\_step** (default: None)

**returns** `str`

#### `create_context()`

```python theme={null}
def create_context(request) -> BuildContext
```

Construct per-build state using the public context and session factories.

**request** *required*

**returns** `BuildContext`

[`BuildContext`](./docker#contree_sdk.docker.BuildContext)

A context owned by this build invocation.

#### `execute_directive()`

```python theme={null}
def execute_directive(directive, context) -> None
```

Execute one directive. Override for policy checks or instrumentation.

**directive** *required*

**context** *required*

**returns** `None`

#### `finalize()`

```python theme={null}
def finalize(context) -> None
```

Commit pending file attachments through the same directive execution hook.

**context** *required*

**returns** `None`

#### `parse()`

```python theme={null}
def parse(text) -> list[DockerKeyword]
```

Return build directives through the configured parser.

**text** *required*

**returns** `list[DockerKeyword]`

list\[[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword)]

The parsed directives in source order.

#### `run_step()`

```python theme={null}
def run_step(directive, context, *, index) -> None
```

Report one directive execution, including nested and synthetic steps.

**directive** *required*

**context** *required*

**index** (default: None)

**returns** `None`

## `class CopyKeyword`

```python theme={null}
class contree_sdk.docker.CopyKeyword(sources, dest, chown, chmod, from_stage)
```

### Attributes

**NAME** `ClassVar[str]`

**chmod** `str`

**chown** `str`

**dest** `str`

**from\_stage** `str`

**sources** `tuple[str, ...]`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> CopyKeyword
```

**args\_text** *required*

**returns** `CopyKeyword`

[`CopyKeyword`](./docker#contree_sdk.docker.CopyKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class DockerKeyword`

```python theme={null}
class contree_sdk.docker.DockerKeyword()
```

Base class. Subclasses implement parse, serialize, execute.

### Attributes

**NAME** `ClassVar[str]`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> DockerKeyword
```

**args\_text** *required*

**returns** `DockerKeyword`

[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class DockerfileParser`

```python theme={null}
class contree_sdk.docker.DockerfileParser(*, keywords, skipped)
```

A per-instance directive registry. Subclass or register custom DockerKeyword classes.

### Methods

#### `parse()`

```python theme={null}
def parse(text) -> list[DockerKeyword]
```

Return directives using this parser’s registry.

**text** *required*

**returns** `list[DockerKeyword]`

list\[[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword)]

The parsed directives in source order.

**raises**

**ValueError** – A directive is unknown or has invalid arguments.

#### `register()`

```python theme={null}
def register(keyword) -> None
```

**keyword** *required*

**returns** `None`

## `class DockerignoreRule`

```python theme={null}
class contree_sdk.docker.DockerignoreRule(negate, regex, raw)
```

One compiled .dockerignore line.

### Attributes

**negate** `bool`

**regex** `Pattern[str]`

**raw** `str`

## `class EnvKeyword`

```python theme={null}
class contree_sdk.docker.EnvKeyword(pairs)
```

### Attributes

**NAME** `ClassVar[str]`

**pairs** `tuple[tuple[str, str], ...]`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> EnvKeyword
```

**args\_text** *required*

**returns** `EnvKeyword`

[`EnvKeyword`](./docker#contree_sdk.docker.EnvKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class FromKeyword`

```python theme={null}
class contree_sdk.docker.FromKeyword(image_ref, alias)
```

### Attributes

**NAME** `ClassVar[str]`

**alias** `str`

**image\_ref** `str`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> FromKeyword
```

**args\_text** *required*

**returns** `FromKeyword`

[`FromKeyword`](./docker#contree_sdk.docker.FromKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class LocalContext`

```python theme={null}
class contree_sdk.docker.LocalContext(root, dockerignore)
```

Read-only handle for the local build context directory.

### Attributes

**root** `Path`

**dockerignore** `tuple[DockerignoreRule, ...]`

tuple\[[`DockerignoreRule`](./docker#contree_sdk.docker.DockerignoreRule), ...]

### Methods

#### `collect()`

```python theme={null}
def collect(sources, dest, *, uid, gid, mode_override) -> list[MappedFile]
```

**sources** *required*

**dest** *required*

**uid** *required*

**gid** *required*

**mode\_override** *required*

**returns** `list[MappedFile]`

#### `from_dir()`

```python theme={null}
@classmethod
def from_dir(root) -> LocalContext
```

**root** *required*

**returns** `LocalContext`

[`LocalContext`](./docker#contree_sdk.docker.LocalContext)

#### `is_ignored()`

```python theme={null}
def is_ignored(rel_path) -> bool
```

**rel\_path** *required*

**returns** `bool`

#### `walk()`

```python theme={null}
def walk(host_path, dest, sources, uid, gid, mode_override) -> list[MappedFile]
```

**host\_path** *required*

**dest** *required*

**sources** *required*

**uid** *required*

**gid** *required*

**mode\_override** *required*

**returns** `list[MappedFile]`

#### `walk_dir()`

```python theme={null}
def walk_dir(host_path, dest, uid, gid, mode_override) -> list[MappedFile]
```

**host\_path** *required*

**dest** *required*

**uid** *required*

**gid** *required*

**mode\_override** *required*

**returns** `list[MappedFile]`

#### `walk_file()`

```python theme={null}
def walk_file(host_path, dest, sources, uid, gid, mode_override) -> list[MappedFile]
```

**host\_path** *required*

**dest** *required*

**sources** *required*

**uid** *required*

**gid** *required*

**mode\_override** *required*

**returns** `list[MappedFile]`

## `class PendingFile`

```python theme={null}
class contree_sdk.docker.PendingFile(instance_path, file_uuid, sha256, uid, gid, mode)
```

### Attributes

**instance\_path** `str`

**file\_uuid** `str`

**sha256** `str`

**uid** `int`

**gid** `int`

**mode** `str`

## `class RunKeyword`

```python theme={null}
class contree_sdk.docker.RunKeyword(parts, shell_form)
```

### Attributes

**NAME** `ClassVar[str]`

**shell\_form** `bool`

**parts** `tuple[str, ...]`

### Methods

#### `build_request()`

```python theme={null}
def build_request(ctx) -> RunRequest
```

Prepare the command for the context’s operation execution hook.

**ctx** *required*

**returns** `RunRequest`

[`RunRequest`](./execution#contree_sdk.execution.RunRequest)

A non-disposable request with the current build state and attachments.

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> RunKeyword
```

**args\_text** *required*

**returns** `RunKeyword`

[`RunKeyword`](./docker#contree_sdk.docker.RunKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class SkippedKeyword`

```python theme={null}
class contree_sdk.docker.SkippedKeyword(name, raw)
```

### Attributes

**NAME** `ClassVar[str]`

**name** `str`

**raw** `str`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `of()`

```python theme={null}
@classmethod
def of(name, raw) -> SkippedKeyword
```

**name** *required*

**raw** *required*

**returns** `SkippedKeyword`

[`SkippedKeyword`](./docker#contree_sdk.docker.SkippedKeyword)

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> DockerKeyword
```

**args\_text** *required*

**returns** `DockerKeyword`

[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class UserKeyword`

```python theme={null}
class contree_sdk.docker.UserKeyword(spec)
```

### Attributes

**NAME** `ClassVar[str]`

**spec** `str`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> UserKeyword
```

**args\_text** *required*

**returns** `UserKeyword`

[`UserKeyword`](./docker#contree_sdk.docker.UserKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `class WorkdirKeyword`

```python theme={null}
class contree_sdk.docker.WorkdirKeyword(path)
```

### Attributes

**NAME** `ClassVar[str]`

**path** `str`

### Methods

#### `execute()`

```python theme={null}
def execute(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `execute_async()`

```python theme={null}
async def execute_async(ctx) -> None
```

**ctx** *required*

**returns** `None`

#### `parse()`

```python theme={null}
@classmethod
def parse(args_text) -> WorkdirKeyword
```

**args\_text** *required*

**returns** `WorkdirKeyword`

[`WorkdirKeyword`](./docker#contree_sdk.docker.WorkdirKeyword)

#### `serialize()`

```python theme={null}
def serialize() -> str
```

Stable text used for layer hashing.

**returns** `str`

## `is_ignored()`

```python theme={null}
def contree_sdk.docker.is_ignored(rel_path, rules) -> bool
```

**rel\_path** *required*

**rules** *required*

**returns** `bool`

## `parse_dockerfile()`

```python theme={null}
def contree_sdk.docker.parse_dockerfile(text) -> list[DockerKeyword]
```

**text** *required*

**returns** `list[DockerKeyword]`

list\[[`DockerKeyword`](./docker#contree_sdk.docker.DockerKeyword)]

## `parse_dockerignore()`

```python theme={null}
def contree_sdk.docker.parse_dockerignore(context_dir) -> tuple[DockerignoreRule, ...]
```

**context\_dir** *required*

**returns** `tuple[DockerignoreRule, ...]`

tuple\[[`DockerignoreRule`](./docker#contree_sdk.docker.DockerignoreRule), ...]

## `substitute()`

```python theme={null}
def contree_sdk.docker.substitute(text, env) -> str
```

**text** *required*

**env** *required*

**returns** `str`
