Is there any alternative for docker to avoid the below error.
RuntimeError: Docker is not installed. Please install Docker to use code execution with agent: Python Developer
Unfortunatelly, no. When you set the allow_code_execution
parameter to True
, the agent leverages the CodeInterpreterTool
as the internal code execution tool. But the CodeInterpreterTool
requires Docker.
2 Likes
Hello.
You can use CodeInterpreterTool like this:
run_codes = CodeInterpreterTool(unsafe_mode=True)
and setting run_codes as tool for agent. doing this, the code will not verify docker and it will run in your local machine.
Be carefull, to production env, it’s very dangerous, but to develop something, you can do this.
Does anyone know a work around for this. It still does not work in Docker
Thank you to the amazing CrewAI team for helping with this.
opened 10:59AM - 18 Jun 25 UTC
bug
### Description
Currently when you set `allow_code_execution=True,` and you are… running in Docker you get an error.
` raise RuntimeError(
RuntimeError: Docker is not installed. Please install Docker to use code execution with agent: Knowledge Pattern Synthesizera`
CrewAI runs well for everything else in docker and the only workaround is to set `run_codes = CodeInterpreterTool(unsafe_mode=True)` this is not ideal.
Can we resolve the issue to work in Docker or state in the Documentation that CrewAI does work work with Docker to run code.
### Steps to Reproduce
Create a standard agent and turn on the flag in the agent
allow_code_execution=True,
Following https://docs.crewai.com/learn/coding-agents
### Expected behavior
Should run the code without errors
### Screenshots/Code snippets
def knowledge_synthesizer(self) -> Agent:
return Agent(
config=self.agents_config['knowledge_synthesizer'],
verbose=True,
memory=True,
allow_code_execution=True,
max_retry_limit=3
)
### Operating System
macOS Sonoma
### Python Version
3.12
### crewAI Version
0.130.0
### crewAI Tools Version
0.130.0
### Virtual Environment
Venv
### Evidence
root@3b97282c2dd0:/crewai/dev/code/create_crewai# crewai run
Running the Crew
Traceback (most recent call last):
File "/crewai/dev/code/create_crewai/src/create_crewai/main.py", line 26, in run
CreateCrewai().crew().kickoff(inputs=inputs)
^^^^^^^^^^^^^^
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 34, in __init__
self.map_all_task_variables()
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 199, in map_all_task_variables
self._map_task_variables(
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 232, in _map_task_variables
self.tasks_config[task_name]["agent"] = agents[agent_name]()
^^^^^^^^^^^^^^^^^^^^
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/crewai/project/utils.py", line 11, in memoized_func
cache[key] = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/crewai/dev/code/create_crewai/src/create_crewai/crew.py", line 55, in knowledge_synthesizer
return Agent(
^^^^^^
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/crewai/agent.py", line 186, in post_init_setup
self._validate_docker_installation()
File "/crewai/dev/code/create_crewai/.venv/lib/python3.12/site-packages/crewai/agent.py", line 670, in _validate_docker_installation
raise RuntimeError(
RuntimeError: Docker is not installed. Please install Docker to use code execution with agent: Knowledge Pattern Synthesizer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/crewai/dev/code/create_crewai/.venv/bin/run_crew", line 10, in <module>
sys.exit(run())
^^^^^
File "/crewai/dev/code/create_crewai/src/create_crewai/main.py", line 28, in run
raise Exception(f"An error occurred while running the crew: {e}")
Exception: An error occurred while running the crew: Docker is not installed. Please install Docker to use code execution with agent: Knowledge Pattern Synthesizer
An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.
root@3b97282c2dd0:/crewai/dev/code/create_crewai#
### Possible Solution
Enable Crewai Code to run in Docker
### Additional context
Is a blocker... as without the fix I will need to run from the file system
If you need to run code in CrewAI and are running Docker this will help
FROM python:3.11-slim
# Install Docker CLI
RUN apt-get update && \
apt-get install -y docker.io && \
rm -rf /var/lib/apt/lists/*
# Set up crewai
WORKDIR /crewai
COPY . /crewai
RUN pip install -e .
CMD ["/bin/bash"]
Then you can run the container like this:
docker run --name crewai-container1 \
--network crew-network \
-v ~/crewai:/crewai \
-v /var/run/docker.sock:/var/run/docker.sock \
-it --rm crewai:latest /bin/bash