> ## 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.interpreters.docker interpreter

<a id="camel.interpreters.docker_interpreter" />

<a id="camel.interpreters.docker_interpreter.DockerInterpreter" />

## DockerInterpreter

```python theme={"system"}
class DockerInterpreter(BaseInterpreter):
```

A class for executing code files or code strings in a docker container.

This class handles the execution of code in different scripting languages
(currently Python and Bash) within a docker container, capturing their
stdout and stderr streams, and allowing user checking before executing code
strings.

**Parameters:**

* **require\_confirm** (bool, optional): If `True`, prompt user before running code strings for security. Defaults to `True`.
* **print\_stdout** (bool, optional): If `True`, print the standard output of the executed code. Defaults to `False`.
* **print\_stderr** (bool, optional): If `True`, print the standard error of the executed code. Defaults to `True`.

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    require_confirm: bool = True,
    print_stdout: bool = False,
    print_stderr: bool = True
):
```

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.__del__" />

### **del**

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

Destructor for the DockerInterpreter class.

This method ensures that the Docker container is removed when the
interpreter is deleted.

<a id="camel.interpreters.docker_interpreter.DockerInterpreter._initialize_if_needed" />

### \_initialize\_if\_needed

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

<a id="camel.interpreters.docker_interpreter.DockerInterpreter._create_file_in_container" />

### \_create\_file\_in\_container

```python theme={"system"}
def _create_file_in_container(self, content: str):
```

<a id="camel.interpreters.docker_interpreter.DockerInterpreter._run_file_in_container" />

### \_run\_file\_in\_container

```python theme={"system"}
def _run_file_in_container(self, file: Path, code_type: str):
```

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.cleanup" />

### cleanup

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

Explicitly stops and removes the Docker container.

This method should be called when you're done with the interpreter
to ensure proper cleanup of Docker resources.

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.run" />

### run

```python theme={"system"}
def run(self, code: str, code_type: str = 'python'):
```

Executes the given code in the container attached to the
interpreter, and captures the stdout and stderr streams.

**Parameters:**

* **code** (str): The code string to execute.
* **code\_type** (str): The type of code to execute (e.g., 'python', 'bash'). (default: obj:`python`)

**Returns:**

str: A string containing the captured stdout and stderr of the
executed code.

<a id="camel.interpreters.docker_interpreter.DockerInterpreter._check_code_type" />

### \_check\_code\_type

```python theme={"system"}
def _check_code_type(self, code_type: str):
```

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.supported_code_types" />

### supported\_code\_types

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

Provides supported code types by the interpreter.

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.update_action_space" />

### update\_action\_space

```python theme={"system"}
def update_action_space(self, action_space: Dict[str, Any]):
```

Updates action space for *python* interpreter

<a id="camel.interpreters.docker_interpreter.DockerInterpreter.execute_command" />

### execute\_command

```python theme={"system"}
def execute_command(self, command: str):
```

Executes a command in the Docker container and returns its output.

**Parameters:**

* **command** (str): The command to execute in the container.

**Returns:**

str: A string containing the captured stdout and stderr of the
executed command.
