OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: openhands can not start due to openhands-runtime not found

Open elvis-cai opened this issue 11 months ago • 17 comments

Is there an existing issue for the same bug?

  • [X] I have checked the existing issues.

Describe the bug and reproduction steps

07:01:59 - openhands:ERROR: docker_runtime.py:113 - [runtime baa72990a45a48ed876a1ed0cc70b946] Container openhands-runtime-baa72990a45a48ed876a1ed0cc70b946 not found.
INFO:     192.168.215.1:47246 - "GET /api/conversations/baa72990a45a48ed876a1ed0cc70b946/list-files HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/docker/api/client.py", line 275, in _raise_for_status
    response.raise_for_status()
  File "/app/.venv/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.47/containers/openhands-runtime-baa72990a45a48ed876a1ed0cc70b946/json

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

Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/engineio/async_drivers/asgi.py", line 75, in __call__
    await self.other_asgi_app(scope, receive, send)
  File "/app/.venv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/app/.venv/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/app/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "/app/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/app/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
    with collapse_excgroups():
  File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/app/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    raise exc
  File "/app/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/server/middleware.py", line 157, in __call__
    response = await self._attach_conversation(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/server/middleware.py", line 137, in _attach_conversation
    request.state.conversation = await session_manager.attach_to_conversation(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/server/session/manager.py", line 197, in attach_to_conversation
    await c.connect()
  File "/app/openhands/server/session/conversation.py", line 43, in connect
    await self.runtime.connect()
  File "/app/openhands/runtime/impl/docker/docker_runtime.py", line 117, in connect
    raise e
  File "/app/openhands/runtime/impl/docker/docker_runtime.py", line 110, in connect
    await call_sync_from_async(self._attach_to_container)
  File "/app/openhands/utils/async_utils.py", line 18, in call_sync_from_async
    result = await coro
             ^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/utils/async_utils.py", line 17, in <lambda>
    coro = loop.run_in_executor(None, lambda: fn(*args, **kwargs))
                                              ^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/runtime/impl/docker/docker_runtime.py", line 297, in _attach_to_container
    self.container = self.docker_client.containers.get(self.container_name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/docker/models/containers.py", line 954, in get
    resp = self.client.api.inspect_container(container_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/docker/api/container.py", line 793, in inspect_container
    return self._result(
           ^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/docker/api/client.py", line 281, in _result
    self._raise_for_status(response)
  File "/app/.venv/lib/python3.12/site-packages/docker/api/client.py", line 277, in _raise_for_status
    raise create_api_error_from_http_exception(e) from e
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/docker/errors.py", line 39, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation) from e
docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.47/containers/openhands-runtime-baa72990a45a48ed876a1ed0cc70b946/json: Not Found ("No such container: openhands-runtime-baa72990a45a48ed876a1ed0cc70b946")

OpenHands Installation

Docker command in README

OpenHands Version

0.18

Operating System

None

Logs, Errors, Screenshots, and Additional Context

how to reproduce

docker pull docker.all-hands.dev/all-hands-ai/runtime:0.18-nikolaik

docker run -it --rm --pull=always \
    -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.18-nikolaik \
    -e LOG_ALL_EVENTS=true \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v ~/.openhands-state:/.openhands-state \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name openhands-app \
    docker.all-hands.dev/all-hands-ai/openhands:0.18

elvis-cai avatar Jan 07 '25 07:01 elvis-cai

+1

daidi avatar Jan 07 '25 07:01 daidi

Also getting this error

MathiasGruber avatar Jan 07 '25 11:01 MathiasGruber

+1

elishaROBINSON avatar Jan 07 '25 11:01 elishaROBINSON

get this issue yesterday on my local env, and resolve it by setting the docker host; the default sock is under my root env not my user env;

os.environ['DOCKER_HOST'] = 'unix:///home/machinedoll-t8/.docker/desktop/docker.sock'

im in ubuntu 20.04

mgloder avatar Jan 07 '25 12:01 mgloder

get this issue yesterday on my local env, and resolve it by setting the docker host; the default sock is under my root env not my user env;

os.environ['DOCKER_HOST'] = 'unix:///home/machinedoll-t8/.docker/desktop/docker.sock'

im in ubuntu 20.04

I'm using a Mac, and my local socks are set up through a symbolic link to /var/run/docker.sock (so they are same), and it worked fine when I switched to version 0.17.

daidi avatar Jan 07 '25 12:01 daidi

Are you all using Linux?

If you leave it running, despite the error, does OpenHands eventually run? This error may not be fatal but I'll get someone to check.

mamoodi avatar Jan 07 '25 14:01 mamoodi

+1,im in macos

BestWhere avatar Jan 07 '25 15:01 BestWhere

Does this happen at startup? When starting a new conversation?

rbren avatar Jan 07 '25 15:01 rbren

@BestWhere in Docker Desktop, if you go to Settings > Advanced and enable `Allow the default Docker socket to be used. Does it fix anything? Again, when you start a conversation, it takes a few minutes to first startup.

mamoodi avatar Jan 07 '25 15:01 mamoodi

@BestWhere in Docker Desktop, if you go to Settings > Advanced and enable `Allow the default Docker socket to be used. Does it fix anything? Again, when you start a conversation, it takes a few minutes to first startup.

It doesn't work.

BestWhere avatar Jan 07 '25 15:01 BestWhere

Does this happen at startup? When starting a new conversation?

Yes. This occurred when I was starting a new conversation. image

BestWhere avatar Jan 07 '25 16:01 BestWhere

get this issue yesterday on my local env, and resolve it by setting the docker host; the default sock is under my root env not my user env;

os.environ['DOCKER_HOST'] = 'unix:///home/machinedoll-t8/.docker/desktop/docker.sock'

im in ubuntu 20.04

I'm using a Mac, and my local socks are set up through a symbolic link to /var/run/docker.sock (so they are same), and it worked fine when I switched to version 0.17.

so brother you mean you fix it by switching to openhands version 0.17?

BestWhere avatar Jan 07 '25 16:01 BestWhere

I have the same problem. I'm using macos. It would be nice to know what the problem is

srcHan-u avatar Jan 07 '25 20:01 srcHan-u

+1

wangyu-ustc avatar Jan 07 '25 22:01 wangyu-ustc

Hey all. Can you try enabling Advanced Settings and filling in the model and API key there and retrying?

For example for claude model would be anthropic/claude-3-5-sonnet-20241022. For gpt-4o it would be openai/gpt-4o.

I think the basic settings is broken for GPT perhaps. We will get this fixed ASAP if that is the case.

mamoodi avatar Jan 07 '25 23:01 mamoodi

had a quick test with 0.19. It works for me now


docker pull docker.all-hands.dev/all-hands-ai/runtime:0.19-nikolaik

docker run -it --rm --pull=always \
    -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.19-nikolaik \
    -e LOG_ALL_EVENTS=true \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v ~/.openhands-state:/.openhands-state \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name openhands-app \
    docker.all-hands.dev/all-hands-ai/openhands:0.19

elvis-cai avatar Jan 08 '25 00:01 elvis-cai

Are others still running into the same issue or has this been resolved by 0.19?

mamoodi avatar Jan 08 '25 15:01 mamoodi

I believe this is fixed in the latest releases. Following the docs should get it working: https://docs.all-hands.dev/modules/usage/installation

Please let me know if this is not the case for you.

mamoodi avatar Jan 22 '25 18:01 mamoodi

I faced the exact same issue. It just stucked on starting runtime. My env is Ubuntu 24.04

jihyun-jeong-854 avatar Jun 21 '25 21:06 jihyun-jeong-854

+1,im in macos

you have success with this on macos?

aidevelop46 avatar Jun 23 '25 18:06 aidevelop46

I faced the exact same issue. It just stucked on starting runtime. My env is Ubuntu 24.04

you have success?

aidevelop46 avatar Jun 23 '25 18:06 aidevelop46