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

Error: Cannot run Docker Image on MacOS #278

Closed
haseeb-heaven opened this issue Mar 28, 2024 · 16 comments
Closed

Error: Cannot run Docker Image on MacOS #278

haseeb-heaven opened this issue Mar 28, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@haseeb-heaven
Copy link

haseeb-heaven commented Mar 28, 2024

Describe the bug
Devin not working from Docker image on MacOS M1 from UI and from command line.

Steps to Reproduce
1.Download the docker file
2.Use the command to run server uvicorn opendevin.server.listen:app --port 3000
3.Use the command to run UI npm run start -- --port 3001

Expected behavior
Devin should work normally

Actual behavior
Devin is not working normally even docker is running from command line.

Additional context

haseeb-mir@Haseebs-MacBook-Pro OpenDevin % uvicorn opendevin.server.listen:app --port 3000                                   
INFO:     Started server process [55399]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)
INFO:     ('127.0.0.1', 55711) - "WebSocket /ws" [accepted]
INFO:     connection open
Task exception was never retrieved
future: <Task finished name='create controller' coro=<Session.create_controller() done, defined at /Users/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/server/session.py:116> exception=DockerException("Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))")>
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 975, in send
    self.connect()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/transport/unixconn.py", line 27, 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/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/http/client.py", line 975, in send
    self.connect()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/transport/unixconn.py", line 27, 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/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/api/client.py", line 213, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
                        ^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/utils/decorators.py", line 44, in inner
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/api/client.py", line 236, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/requests/adapters.py", line 501, 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/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/server/session.py", line 133, in create_controller
    self.controller = AgentController(self.agent, workdir=directory, callbacks=[self.on_agent_event])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/controller/__init__.py", line 37, in __init__
    self.command_manager = CommandManager(workdir)
                           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/controller/command_manager.py", line 9, in __init__
    self.shell = DockerInteractive(id="default", workspace_dir=dir)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/sandbox/sandbox.py", line 124, in __init__
    self.restart_docker_container()
  File "/Users/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/sandbox/sandbox.py", line 197, in restart_docker_container
    self.stop_docker_container()
  File "/Users/haseeb-mir/Documents/Code/Python/OpenDevin/opendevin/sandbox/sandbox.py", line 181, in stop_docker_container
    docker_client = docker.from_env()
                    ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/client.py", line 94, in from_env
    return cls(
           ^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/envs/heaven-env/lib/python3.11/site-packages/docker/api/client.py", line 220, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

SOLVED

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock
@haseeb-heaven haseeb-heaven added the bug Something isn't working label Mar 28, 2024
@haseeb-heaven haseeb-heaven changed the title Docker Image running error on MacOS Error: Cannot run Docker Image on MacOS Mar 28, 2024
@1of13
Copy link

1of13 commented Mar 28, 2024

On mac, using "python -m uvicorn opendevin.server.listen:app --port 3000" eliminates these errors.

@haseeb-heaven
Copy link
Author

Thanks but I solved this error by finding the correct environment file for this at this location

docker_client = docker.DockerClient(base_url='unix:///Users/haseeb-mir/.docker/run/docker.sock')

@OSH212
Copy link

OSH212 commented Mar 28, 2024

On mac, using "python -m uvicorn opendevin.server.listen:app --port 3000" eliminates these errors.

it doesn't

@haseeb-heaven
Copy link
Author

On mac, using "python -m uvicorn opendevin.server.listen:app --port 3000" eliminates these errors.

it doesn't

Try the solution I provided its working for me.

@OSH212
Copy link

OSH212 commented Mar 28, 2024

which files did you update ?

@1of13
Copy link

1of13 commented Mar 28, 2024

Interesting...It worked for me.

SCR-20240327-shja SCR-20240327-sjft

@OSH212
Copy link

OSH212 commented Mar 28, 2024

Interesting...It worked for me.

give it its own code and the error so it can fix itself :)

@iFurySt
Copy link
Contributor

iFurySt commented Mar 28, 2024

Thanks but I solved this error by finding the correct environment file for this at this location

docker_client = docker.DockerClient(base_url='unix:///Users/haseeb-mir/.docker/run/docker.sock')

does this exist? 🤔

ls -lh /var/run/docker.sock

@haseeb-heaven
Copy link
Author

Thanks but I solved this error by finding the correct environment file for this at this location

docker_client = docker.DockerClient(base_url='unix:///Users/haseeb-mir/.docker/run/docker.sock')

does this exist? 🤔

ls -lh /var/run/docker.sock

No that file in var/run/docker.sock doesn't exist for me that why I changed the PATH for that on MacOS.

@haseeb-heaven
Copy link
Author

which files did you update ?

I updated server/session.py file with all instances of docker_client variable with my PATH of docker.

in stop_docker_container and restart_docker_container methods I changed the docker_client to this.

  • from this
docker_client = docker.from_env()
  • to this
docker_client = docker.DockerClient(base_url='unix:///Users/haseeb-mir/.docker/run/docker.sock')`

@haseeb-heaven
Copy link
Author

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock

@iFurySt
Copy link
Contributor

iFurySt commented Mar 28, 2024

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock

Maybe you can create a soft link :)

@haseeb-heaven
Copy link
Author

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock

Maybe you can create a soft link :)

But this is only issue for MacOS docker PATH and not for everyone if others need it we can merge in PR in readme then

@OSH212
Copy link

OSH212 commented Mar 29, 2024

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock

Maybe you can create a soft link :)

But this is only issue for MacOS docker PATH and not for everyone if others need it we can merge in PR in readme then

Thank you 🙏

@forgingdestiny
Copy link

That worked for me - setting the MacOS docker path - I use Docker Desktop 4.22.0

I'm finally up and running!

image

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock

Maybe you can create a soft link :)

@haseeb-heaven
Copy link
Author

That worked for me - setting the MacOS docker path - I use Docker Desktop 4.22.0

I'm finally up and running!

image

I finally solved it by updating my Docker host path like this.

export DOCKER_HOST=unix:///Users/haseeb-mir/.docker/run/docker.sock

Maybe you can create a soft link :)

I dont really get what soft link means here? could you explain that i would surely help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants