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

Hint: Connection to Docker failed. Is docker or Docker Desktop running? #158

Open
zkMyst opened this issue Sep 27, 2024 · 11 comments
Open

Comments

@zkMyst
Copy link

zkMyst commented Sep 27, 2024

Hi,

I've got Docker desktop running, but after starting a new execution the agent errors with:


Error: Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/client.py", line 207, in __init__
    self._version = self._retrieve_server_version()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/client.py", line 230, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

I'm running python main.py in a miniconda environement (I can see (base) in my terminal). Does anyone know what this could be due to ?

For context this is the most recent Traceback:

Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connectionpool.py", line 789, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connectionpool.py", line 495, in _make_request
    conn.request(
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connection.py", line 398, in request
    self.endheaders()
  File "/opt/miniconda3/lib/python3.12/http/client.py", line 1331, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/miniconda3/lib/python3.12/http/client.py", line 1091, in _send_output
    self.send(msg)
  File "/opt/miniconda3/lib/python3.12/http/client.py", line 1035, in send
    self.connect()
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/transport/unixconn.py", line 26, in connect
    sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connectionpool.py", line 843, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/util/retry.py", line 474, in increment
    raise reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connectionpool.py", line 789, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connectionpool.py", line 495, in _make_request
    conn.request(
  File "/opt/miniconda3/lib/python3.12/site-packages/urllib3/connection.py", line 398, in request
    self.endheaders()
  File "/opt/miniconda3/lib/python3.12/http/client.py", line 1331, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/miniconda3/lib/python3.12/http/client.py", line 1091, in _send_output
    self.send(msg)
  File "/opt/miniconda3/lib/python3.12/http/client.py", line 1035, in send
    self.connect()
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/transport/unixconn.py", line 26, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/client.py", line 223, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
                        ^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/utils/decorators.py", line 44, in inner
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/client.py", line 246, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/requests/adapters.py", line 682, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/martinb/Documents/AgentZero/agent-zero/python/helpers/docker.py", line 21, in init_docker
    self.client = docker.from_env()
                  ^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/client.py", line 94, in from_env
    return cls(
           ^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/client.py", line 207, in __init__
    self._version = self._retrieve_server_version()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/docker/api/client.py", line 230, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/martinb/Documents/AgentZero/agent-zero/main.py", line 157, in <module>
    initialize()
  File "/Users/martinb/Documents/AgentZero/agent-zero/main.py", line 69, in initialize
    chat(agent0)
  File "/Users/martinb/Documents/AgentZero/agent-zero/main.py", line 107, in chat
    assistant_response = agent.message_loop(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martinb/Documents/AgentZero/agent-zero/agent.py", line 124, in message_loop
    tools_result = self.process_tools(agent_response) # process tools requested in agent message
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martinb/Documents/AgentZero/agent-zero/agent.py", line 250, in process_tools
    response = tool.execute(**tool_args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martinb/Documents/AgentZero/agent-zero/python/tools/code_execution_tool.py", line 27, in execute
    self.prepare_state()
  File "/Users/martinb/Documents/AgentZero/agent-zero/python/tools/code_execution_tool.py", line 56, in prepare_state
    docker = DockerContainerManager(name=self.agent.config.code_exec_docker_name, image=self.agent.config.code_exec_docker_image, ports=self.agent.config.code_exec_docker_ports, volumes=self.agent.config.code_exec_docker_volumes)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martinb/Documents/AgentZero/agent-zero/python/helpers/docker.py", line 15, in __init__
    self.init_docker()
  File "/Users/martinb/Documents/AgentZero/agent-zero/python/helpers/docker.py", line 28, in init_docker
    time.sleep(5) # try again in 5 seconds
    ^^^^^^^^^^^^^
KeyboardInterrupt
@MovLab2
Copy link

MovLab2 commented Sep 27, 2024

From this you posted, it is an older version. (python main.py). Try updating and check again.. (run_ui.py) is the new way. Start Docker Desktop before running run_ui.py. (conda create --name agentzero python=3.10) (conda activate agentzero) now do install again from the github page. Follow the instructions and it should work fine then.

@zkMyst
Copy link
Author

zkMyst commented Sep 27, 2024

Updated, ran the insall commands and:

Connection to Docker failed. Is docker or Docker Desktop running?
Traceback (most recent call last):
  File "/opt/miniconda3/envs/agentzero/lib/python3.10/site-packages/docker/api/client.py", line 207, in __init__
    self._version = self._retrieve_server_version()
  File "/opt/miniconda3/envs/agentzero/lib/python3.10/site-packages/docker/api/client.py", line 230, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

@MovLab2
Copy link

MovLab2 commented Sep 27, 2024

did you set the correct settings? and change your .env file? put the correct api keys in?

main chat model used by agents (smarter, more accurate)

chat_llm = models.get_openai_chat(model_name="gpt-4o-mini", temperature=0)
# chat_llm = models.get_ollama_chat(model_name="gemma2:latest", temperature=0)
# chat_llm = models.get_lmstudio_chat(model_name="lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF", temperature=0)
# chat_llm = models.get_openrouter_chat(model_name="mattshumer/reflection-70b:free")
# chat_llm = models.get_azure_openai_chat(deployment_name="gpt-4o-mini", temperature=0)
# chat_llm = models.get_anthropic_chat(model_name="claude-3-5-sonnet-20240620", temperature=0)
# chat_llm = models.get_google_chat(model_name="gemini-1.5-flash", temperature=0)
# chat_llm = models.get_groq_chat(model_name="llama-3.1-70b-versatile", temperature=0)

# utility model used for helper functions (cheaper, faster)
utility_llm = chat_llm # change if you want to use a different utility model

# embedding model used for memory
embedding_llm = models.get_openai_embedding(model_name="text-embedding-3-small")
# embedding_llm = models.get_ollama_embedding(model_name="nomic-embed-text")
# embedding_llm = models.get_huggingface_embedding(model_name="sentence-transformers/all-MiniLM-L6-v2")
# embedding_llm = models.get_lmstudio_embedding(model_name="nomic-ai/nomic-embed-text-v1.5-GGUF")

@zkMyst
Copy link
Author

zkMyst commented Sep 27, 2024

Yes didn't change anything other than input my api keys for openAI and Perplexity...

@3clyp50
Copy link
Contributor

3clyp50 commented Sep 27, 2024

@zkMyst Please use Python 3.12, though I don't think it's the only issue there. Are you sure that your user is in the Docker user group?

$ sudo usermod -aG docker $USER

@zkMyst
Copy link
Author

zkMyst commented Sep 27, 2024

Sorry im on MacOS, dont think there is user management with the desktop app there.

@3clyp50
Copy link
Contributor

3clyp50 commented Sep 28, 2024

@zkMyst I'm sorry, I've been inactive. Try this, and let me know please:
Pull up the terminal and do:

id -nG

that is going to show you all the groups in the system, so you can verify if your user is in the 'docker' group.

Then you should be able to add your user to docker group with this command:

sudo dseditgroup -o edit -a $USER -t user docker

In normal operations it's better to let Docker Desktop manage user permissions, but still. Let me know.

@gregoryStarr
Copy link

gregoryStarr commented Sep 29, 2024

FIXED!

I had this issue as well. I spent nearly 3 hours on it. My fnal fix was to completely uninstall docker (and all its components) and reinstall it. verify it via the terminal (you must enable starting when system starts , and enable cli) otherwise it wont work

P.S. Im also running a mac

@3clyp50
Copy link
Contributor

3clyp50 commented Sep 29, 2024

FIXED!

I had this issue as well. I spent nearly 3 hours on it. My fnal fix was to completely uninstall docker (and all its components) and reinstall it. verify it via the terminal (you must enable starting when system starts , and enable cli) otherwise it wont work

P.S. Im also running a mac

Thank you, this will prove useful for some users. I had similar issues with Linux VMs that doesn't support nested virtualization and require a docker-ce setup to run A0 with. I'll write docs on the matter.

@afanjul
Copy link

afanjul commented Oct 7, 2024

Ok I found the problem, in macOS you have to check the "Allow the default Docker socket to be used (requires password)" checkbox to allow other tools to interact with docker socket.

Screenshot 2024-10-07 at 11 09 37

Now it works perfectly...

@frdel maybe you could add it to the macOS installation instructions...

@3clyp50
Copy link
Contributor

3clyp50 commented Oct 7, 2024

Ok I found the problem, in macOS you have to check the "Allow the default Docker socket to be used (requires password)" checkbox to allow other tools to interact with docker socket.

Now it works perfectly...

@frdel maybe you could add it to the macOS installation instructions...

Thank you kindly, I'm adding this exception to the docs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants