Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Code execution is set to be run in docker (default behaviour) but docker is not running. #1381

Closed
tyler-suard-parker opened this issue Jan 23, 2024 · 18 comments
Labels
code-execution execute generated code dev development experience/productivity docker Issues relating to Docker

Comments

@tyler-suard-parker
Copy link
Contributor

Describe the issue

This error appears even when I have no plans to run any code. It is really annoying, and sometimes I can't set my environment variables to get rid of it.

Steps to reproduce

Create agents and run them

Screenshots and logs

No response

Additional Information

No response

@olgavrou
Copy link
Member

Hi @tyler-suard-parker

This is a recent change that was made for safety around code execution, you can see how to disable the default behaviour here if you wish to do so.

If you are still having trouble can you please add some code so that we can see where the problem is, and let us know your dev operating system, etc

@sonichi
Copy link
Contributor

sonichi commented Jan 23, 2024

Maybe we can add in the doc about disabling code execution entirely, by setting code_execution_config=False

@tyler-suard-parker
Copy link
Contributor Author

Can we just set code execution to be disabled by default?

@olgavrou
Copy link
Member

This would also be a breaking change; we could consider it for future releases. @sonichi I'll update the documentation

@ekzhu ekzhu added code-execution execute generated code dev development experience/productivity labels Jan 24, 2024
@austinhumes-valtech
Copy link

austinhumes-valtech commented Feb 1, 2024

I just updated to the latest version 0.2.9 and received the error:

ERROR: Code execution is set to be run in docker (default behaviour) but docker is not running.
The options available are:
- Make sure docker is running (advised approach for code execution)
- Set "use_docker": False in code_execution_config
- Set AUTOGEN_USE_DOCKER to "0/False/no" in your environment variables

even though I had code_execution_config=False already, while not using Docker at all. Once I just started Docker Desktop and restarted my Autogen app, it ran without error. Does that mean that Docker just has to be running on the same machine, even if it's not used with Autogen?

Thanks in advance @olgavrou @sonichi

@olgavrou
Copy link
Member

olgavrou commented Feb 1, 2024

Hi @austinhumes-valtech
If you had code_execution_config set to False then it shouldn't complain about docker. Could you provide a sample of your code maybe so that we can investigate?

@austinhumes-valtech
Copy link

Hi @austinhumes-valtech If you had code_execution_config set to False then it shouldn't complain about docker. Could you provide a sample of your code maybe so that we can investigate?

Hi @olgavrou thanks for the quick response! I'm using a group chat. Here's some code samples:

class AutogenChat():
    def __init__(self, chat_id=None, websocket=None):
        self.websocket = websocket
        self.chat_id = chat_id
        self.client_sent_queue = asyncio.Queue()
        self.client_receive_queue = asyncio.Queue()  
        
        self.user_proxy = UserProxyWebAgent( 
            name="user_proxy",
            human_input_mode="ALWAYS", 
            system_message="""
                Agent to represent the human user.
                Always provide the user with a easy to understand response, rather than just data. For example, if a large amount of data is returned from a function call, provide the user with a summary of the results instead of the raw API response, for example: 
                1. Item 1
                2. Item 2
                3. Item 3
            """,
            max_consecutive_auto_reply=5,
            is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"),
            code_execution_config=False
        )

   ...
class UserProxyWebAgent(autogen.UserProxyAgent):
    def __init__(self, *args, **kwargs):
        super(UserProxyWebAgent, self).__init__(*args, **kwargs)
        self._reply_func_list = []
        self.register_reply([Agent, None], ConversableAgent.generate_oai_reply)
        self.register_reply([Agent, None], ConversableAgent.generate_code_execution_reply)
        self.register_reply([Agent, None], ConversableAgent.generate_function_call_reply)
        self.register_reply([Agent, None], UserProxyWebAgent.a_check_termination_and_human_reply)

    ...

Hope that helps! Thanks!

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 2, 2024

It only shows the set up for the user proxy, what about the assistant agent? Did you set the code_execution_config=False for the assistant agent?

Also, I see you are re-registering the generate_code_execution_reply function. You probably want to remove that and only register it depending on whether you are turning on code execution.

@sonichi
Copy link
Contributor

sonichi commented Feb 11, 2024

@austinhumes-valtech does this error still occur with the latest version? If so, could you share a little reproducible example?

@sonichi sonichi added the docker Issues relating to Docker label Feb 11, 2024
@doursand
Copy link

doursand commented Feb 20, 2024

I managed to solved this issue adding a "use_docker": False inside the code_execution_config dict like this :

user_proxy = autogen.UserProxyAgent( name="user_proxy", human_input_mode="NEVER", max_consecutive_auto_reply=10, is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"), code_execution_config={"work_dir": "web", "use_docker": False}, llm_config=llm_config_mistral, system_message="""Reply TERMINATE if the task has been solved at full satisfaction. Otherwise, reply CONTINUE, or the reason why the task is not solved yet.""" )

@olgavrou
Copy link
Member

Great! this is the intended workaround :) I'll close the issue but feel free to reopen if another issue occurs

@g-o-o-g-l-e
Copy link

I got RuntimeError: Please ensure Docker is running on your system.

@g-o-o-g-l-e
Copy link

on the lastest version

@g-o-o-g-l-e
Copy link

my code is from docker_games import Minecraft

minecraft = Minecraft('creepers_go_boom', '2GB', '/home/stefano/mc_data')
minecraft.add_ports(25565, 25565)
minecraft.accept_license()
minecraft.online_mode()

minecraft.start()

@ekzhu
Copy link
Collaborator

ekzhu commented Mar 8, 2024

@g-o-o-g-l-e you need to install docker on your machine

@honestAnt
Copy link

honestAnt commented May 13, 2024

This is because the docker client integrated with autogen uses the default configuration (mine is macos, the default port is 2375), and DOCKER_HOST needs to be modified to solve the problem.
image

So you can add DOCK_HOST configuration to the environment variable to solve the problem:
image
image

@g-o-o-g-l-e
Copy link

thanks

@AbhijitManepatil
Copy link

I managed to solved this issue adding a "use_docker": False inside the code_execution_config dict like this :

user_proxy = autogen.UserProxyAgent( name="user_proxy", human_input_mode="NEVER", max_consecutive_auto_reply=10, is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"), code_execution_config={"work_dir": "web", "use_docker": False}, llm_config=llm_config_mistral, system_message="""Reply TERMINATE if the task has been solved at full satisfaction. Otherwise, reply CONTINUE, or the reason why the task is not solved yet.""" )

"use_docker": False works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-execution execute generated code dev development experience/productivity docker Issues relating to Docker
Projects
None yet
Development

No branches or pull requests

9 participants