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

# Camel.runtimes.docker runtime

<a id="camel.runtimes.docker_runtime" />

<a id="camel.runtimes.docker_runtime.DockerRuntime" />

## DockerRuntime

```python theme={"system"}
class DockerRuntime(BaseRuntime):
```

A class representing a runtime environment using Docker.
This class automatically wraps functions to be executed
in a Docker container.

**Parameters:**

* **image** (str): The name of the Docker image to use for the runtime.
* **port** (int): The port number to use for the runtime API. (default: :obj: `8000`)
* **remove** (bool): Whether to remove the container after stopping it. ' (default: :obj:`True`)
* **kwargs** (dict): Additional keyword arguments to pass to the Docker client.

<a id="camel.runtimes.docker_runtime.DockerRuntime.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    image: str,
    port: int = 8000,
    remove: bool = True,
    **kwargs
):
```

<a id="camel.runtimes.docker_runtime.DockerRuntime.mount" />

### mount

```python theme={"system"}
def mount(self, path: str, mount_path: str):
```

Mount a local directory to the container.

**Parameters:**

* **path** (str): The local path to mount.
* **mount\_path** (str): The path to mount the local directory to in the container.

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.copy" />

### copy

```python theme={"system"}
def copy(self, source: str, dest: str):
```

Copy a file or directory to the container.

**Parameters:**

* **source** (str): The local path to the file.
* **dest** (str): The path to copy the file to in the container.

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.add_task" />

### add\_task

```python theme={"system"}
def add_task(self, task: TaskConfig):
```

Add a task to run a command inside the container when building.
Similar to `docker exec`.

**Parameters:**

* **task** (TaskConfig): The configuration for the task.

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.exec_run" />

### exec\_run

```python theme={"system"}
def exec_run(self, task: TaskConfig):
```

Run a command inside this container. Similar to `docker exec`.

**Parameters:**

* **task** (TaskConfig): The configuration for the task.

**Returns:**

(ExecResult): A tuple of (exit\_code, output)
exit\_code: (int):
Exit code for the executed command or `None` if
either `stream` or `socket` is `True`.
output: (generator, bytes, or tuple):
If `stream=True`, a generator yielding response chunks.
If `socket=True`, a socket object for the connection.
If `demux=True`, a tuple of two bytes: stdout and stderr.
A bytestring containing response data otherwise.

<a id="camel.runtimes.docker_runtime.DockerRuntime.build" />

### build

```python theme={"system"}
def build(self, time_out: int = 15):
```

Build the Docker container and start it.

**Parameters:**

* **time\_out** (int): The number of seconds to wait for the container to start. (default: :obj:`15`)

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.add" />

### add

```python theme={"system"}
def add(
    self,
    funcs: Union[FunctionTool, List[FunctionTool]],
    entrypoint: str,
    redirect_stdout: bool = False,
    arguments: Optional[Dict[str, Any]] = None
):
```

Add a function or list of functions to the runtime.

**Parameters:**

* **funcs** (Union\[FunctionTool, List\[FunctionTool]]): The function or list of functions to add.
* **entrypoint** (str): The entrypoint for the function.
* **redirect\_stdout** (bool): Whether to return the stdout of the function. (default: :obj:`False`)
* **arguments** (Optional\[Dict\[str, Any]]): The arguments for the function. (default: :obj:`None`)

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.reset" />

### reset

```python theme={"system"}
def reset(self):
```

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.cleanup" />

### cleanup

```python theme={"system"}
def cleanup(self):
```

Stop and optionally remove the Docker container.

Uses the instance's :attr:`remove` setting to decide whether to
remove the container after stopping. For a one-off override,
use :meth:`stop` with the `__INLINE_CODE_2__` argument.

<a id="camel.runtimes.docker_runtime.DockerRuntime.stop" />

### stop

```python theme={"system"}
def stop(self, remove: Optional[bool] = None):
```

Stop the Docker container and release resources.

**Parameters:**

* **remove** (Optional\[bool]): If set, overrides the instance's :attr:`remove` setting for this call only (e.g. `__INLINE_CODE_1____INLINE_CODE_2__None`)

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.ok" />

### ok

```python theme={"system"}
def ok(self):
```

**Returns:**

bool: Whether the API Server is running.

<a id="camel.runtimes.docker_runtime.DockerRuntime.wait" />

### wait

```python theme={"system"}
def wait(self, timeout: int = 10):
```

Wait for the API Server to be ready.

**Parameters:**

* **timeout** (int): The number of seconds to wait. (default: :obj:`10`) (default: 10)

**Returns:**

bool: Whether the API Server is ready.

<a id="camel.runtimes.docker_runtime.DockerRuntime.__enter__" />

### **enter**

```python theme={"system"}
def __enter__(self):
```

**Returns:**

DockerRuntime: The DockerRuntime instance.

<a id="camel.runtimes.docker_runtime.DockerRuntime.__exit__" />

### **exit**

```python theme={"system"}
def __exit__(
    self,
    exc_type,
    exc_val,
    exc_tb
):
```

Exit the context manager.

<a id="camel.runtimes.docker_runtime.DockerRuntime.docs" />

### docs

```python theme={"system"}
def docs(self):
```

**Returns:**

str: The URL for the API documentation.
