OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Exception: Failed to start container

Open pandaupc opened this issue 1 year ago β€’ 15 comments

Describe the bug

Setup and configuration

Current version:

My config.toml and environment vars (be sure to redact API keys):

My model and agent (you can see these settings in the UI):

  • Model:gpt4-preview-1106
  • Agent:

Commands I ran to install and run OpenDevin:

Steps to Reproduce: 1.make run

Logs, error messages, and screenshots:

Additional Context

12:52:49 - opendevin:INFO: sandbox.py:371 - waiting for container to start: 1, container status: exited 12:52:49 - opendevin:INFO: sandbox.py:364 - container exited 12:52:49 - opendevin:INFO: sandbox.py:365 - container logs: 12:52:49 - opendevin:INFO: sandbox.py:366 - b'' 12:52:49 - opendevin:ERROR: manager.py:134 - Error creating controller. Traceback (most recent call last): File "/home/shouwangzhe/code/OpenDevin/opendevin/server/agent/manager.py", line 125, in create_controller self.controller = AgentController( ^^^^^^^^^^^^^^^^ File "/home/shouwangzhe/code/OpenDevin/opendevin/controller/agent_controller.py", line 86, in init self.command_manager = CommandManager( ^^^^^^^^^^^^^^^ File "/home/shouwangzhe/code/OpenDevin/opendevin/controller/command_manager.py", line 14, in init self.shell = DockerInteractive( ^^^^^^^^^^^^^^^^^^ File "/home/shouwangzhe/code/OpenDevin/opendevin/sandbox/sandbox.py", line 135, in init self.restart_docker_container() File "/home/shouwangzhe/code/OpenDevin/opendevin/sandbox/sandbox.py", line 376, in restart_docker_container raise Exception('Failed to start container') Exception: Failed to start container INFO: 127.0.0.1:33876 - "DELETE /messages HTTP/1.1" 200 OK

pandaupc avatar Apr 09 '24 04:04 pandaupc

Can you provide more information about your setup?

e.g., Operating system, Docker version?

What is the output of docker ps on your machine?

xingyaoww avatar Apr 09 '24 09:04 xingyaoww

(opendevin) shouwangzhe@shouwangzhe:~/code/OpenDevin$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

pandaupc avatar Apr 09 '24 14:04 pandaupc

(opendevin) shouwangzhe@shouwangzhe:~/code/OpenDevin$ docker --version Docker version 26.0.0, build 2ae903e

ubuntu

pandaupc avatar Apr 09 '24 14:04 pandaupc

Try to pull the latest changes and run make build after finishing make run if config.py is already there

anasdorbani avatar Apr 09 '24 14:04 anasdorbani

I pull the latest changes,but the error is the same and i can not find the config.py file.

(opendevin) shouwangzhe@shouwangzhe:~/code/OpenDevin$ systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2024-04-08 22:54:32 CST; 1 day 9h ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 1962 (dockerd) Tasks: 38 Memory: 766.9M CPU: 50.311s CGroup: /system.slice/docker.service └─1962 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

4月 08 23:41:00 shouwangzhe dockerd[1962]: time="2024-04-08T23:41:00.939003087+08:00" level=info msg="ignoring event" container=0> 4月 08 23:43:02 shouwangzhe dockerd[1962]: time="2024-04-08T23:43:02.126512133+08:00" level=info msg="ignoring event" container=f> 4月 08 23:44:06 shouwangzhe dockerd[1962]: time="2024-04-08T23:44:06.066262267+08:00" level=info msg="ignoring event" container=7> 4月 09 12:50:23 shouwangzhe dockerd[1962]: time="2024-04-09T12:50:23.333059724+08:00" level=info msg="ignoring event" container=5>

Info in ui

assistant avatar Hi! I'm OpenDevin, an AI Software Engineer. What would you like to build with me today?

assistant avatar Error creating controller. Please check Docker is running using docker ps.

Info in terminal

08:30:40 - opendevin:INFO: sandbox.py:383 - waiting for container to start: 1, container status: exited 08:30:40 - opendevin:INFO: sandbox.py:376 - container exited 08:30:40 - opendevin:INFO: sandbox.py:377 - container logs: 08:30:40 - opendevin:INFO: sandbox.py:378 - b'' 08:30:40 - opendevin:ERROR: manager.py:134 - Error creating controller. Traceback (most recent call last): File "/home/shouwangzhe/code/OpenDevin/opendevin/server/agent/manager.py", line 125, in create_controller self.controller = AgentController( ^^^^^^^^^^^^^^^^ File "/home/shouwangzhe/code/OpenDevin/opendevin/controller/agent_controller.py", line 86, in init self.command_manager = CommandManager( ^^^^^^^^^^^^^^^ File "/home/shouwangzhe/code/OpenDevin/opendevin/controller/command_manager.py", line 14, in init self.shell = DockerInteractive( ^^^^^^^^^^^^^^^^^^ File "/home/shouwangzhe/code/OpenDevin/opendevin/sandbox/sandbox.py", line 135, in init self.restart_docker_container() File "/home/shouwangzhe/code/OpenDevin/opendevin/sandbox/sandbox.py", line 388, in restart_docker_container raise Exception('Failed to start container') Exception: Failed to start container INFO: 127.0.0.1:47860 - "DELETE /messages HTTP/1.1" 200 OK

pandaupc avatar Apr 10 '24 00:04 pandaupc

Can you provide more information about your setup?

e.g., Operating system, Docker version?

What is the output of docker ps on your machine?

Same error, image

environment---------------------------------------- windows 10+wsl ubuntu-22.04+LM Studio+docker on version 4.4.4.

Steps to Reproduce:-------------------------------- git pull make build make run

terminal--------------------------------------------- (opendev) agent@DESKTOP-OJHF2BM:~/OpenDevin$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ee9e9ee91ce6 ghcr.io/opendevin/sandbox "/usr/sbin/sshd -D -…" 3 minutes ago Up 3 minutes sandbox-4223ab84-bff9-4880-8af9-6db03910bfcd logs-------------------------------------------------- 09:49:14 - opendevin:INFO: sandbox.py:119 - Using workspace directory: /home/agent/OpenDevin/workspace 09:49:15 - opendevin:INFO: sandbox.py:210 - Connecting to opendevin@localhost via ssh. If you encounter any issues, you can try ssh -v -p 2222 opendevin@localhost with the password 'c686280f-7d5a-4cb3-b7e2-46b3ebc64a9f' and report the issue on GitHub. 09:49:16 - opendevin:ERROR: manager.py:134 - Error creating controller. Traceback (most recent call last): File "/home/agent/OpenDevin/opendevin/server/agent/manager.py", line 125, in create_controller self.controller = AgentController( ^^^^^^^^^^^^^^^^ File "/home/agent/OpenDevin/opendevin/controller/agent_controller.py", line 86, in init self.command_manager = CommandManager( ^^^^^^^^^^^^^^^ File "/home/agent/OpenDevin/opendevin/controller/command_manager.py", line 14, in init self.shell = DockerInteractive( ^^^^^^^^^^^^^^^^^^ File "/home/agent/OpenDevin/opendevin/sandbox/sandbox.py", line 139, in init self.start_ssh_session() File "/home/agent/OpenDevin/opendevin/sandbox/sandbox.py", line 213, in start_ssh_session self.ssh.login(hostname, username, self._ssh_password, port=2222) File "/home/agent/miniconda3/envs/opendev/lib/python3.11/site-packages/pexpect/pxssh.py", line 424, in login raise ExceptionPxssh('Could not establish connection to host') pexpect.pxssh.ExceptionPxssh: Could not establish connection to host

zhonggegege avatar Apr 10 '24 01:04 zhonggegege

same issue for me

reate_api_error_from_http_exception raise cls(e, response=response, explanation=explanation) from e docker.errors.APIError: 400 Client Error for http+docker://localhost/v1.44/containers/939c0ed7c9e4f6265e400d84e990bcabea4b85217ed8bfa4b2e4eb3803884e33/start: Bad Request ("failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/sbin/sshd": stat /usr/sbin/sshd: no such file or directory: unknown")

ajeema avatar Apr 10 '24 02:04 ajeema

Same for me, I m using Windows 11 WSL. self.ssh.login(hostname, username, self._ssh_password, port=2222) File "/home/catto/anaconda3/envs/OpenDevin/lib/python3.11/site-packages/pexpect/pxssh.py", line 424, in login raise ExceptionPxssh('Could not establish connection to host') pexpect.pxssh.ExceptionPxssh: Could not establish connection to host

ve-cattozzi avatar Apr 10 '24 06:04 ve-cattozzi

Same for me

Message in the webapp (front-end): Error creating controller. Please check Docker is running using docker ps.

Message in the back-end terminal:

09:49:39 - opendevin:ERROR: manager.py:134 - Error creating controller.
Traceback (most recent call last):
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connection.py", line 400, in request
    self.endheaders()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1314, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1074, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1018, in send
    self.connect()
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/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 "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/urllib3/connection.py", line 400, in request
    self.endheaders()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1314, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1074, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1018, in send
    self.connect()
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/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 "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/api/client.py", line 213, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
                        ^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/utils/decorators.py", line 44, in inner
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/api/client.py", line 236, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/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/luca/Documents/devel/OpenDevin/opendevin/server/agent/manager.py", line 125, in create_controller
    self.controller = AgentController(
                      ^^^^^^^^^^^^^^^^
  File "/Users/luca/Documents/devel/OpenDevin/opendevin/controller/agent_controller.py", line 86, in __init__
    self.command_manager = CommandManager(
                           ^^^^^^^^^^^^^^^
  File "/Users/luca/Documents/devel/OpenDevin/opendevin/controller/command_manager.py", line 14, in __init__
    self.shell = DockerInteractive(
                 ^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Documents/devel/OpenDevin/opendevin/sandbox/sandbox.py", line 134, in __init__
    if not self.is_container_running():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Documents/devel/OpenDevin/opendevin/sandbox/sandbox.py", line 320, in is_container_running
    docker_client = docker.from_env()
                    ^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/client.py", line 94, in from_env
    return cls(
           ^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Library/Caches/pypoetry/virtualenvs/opendevin-rpD-2hkp-py3.12/lib/python3.12/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'))

my configuration: MacBook M1, Sonoma Python 3.10.4 Docker version 26.0.0, build 2ae903e86c Poetry (version 1.8.2)

opendevin version:

commit 707ab7b3f84fb5664ff63da0b52e7b0d2e4df545 (HEAD -> main, origin/main, origin/HEAD)
Author: Alex BΓ€uerle <[email protected]>
Date:   Tue Apr 9 17:42:16 2024 -0700

using ollama as LLM

config.toml

LLM_API_KEY="ollama"
LLM_MODEL="ollama/<model_name>"
LLM_EMBEDDING_MODEL="local"
LLM_BASE_URL="http://localhost:<port_number>"
WORKSPACE_DIR="./workspace"

ls-cnr avatar Apr 10 '24 07:04 ls-cnr

I have the same issue, please fix it.

image

CapyBarr1 avatar Apr 10 '24 09:04 CapyBarr1

I added RUN mkdir /var/run/sshd

destroyed all local docker files and ran again and had more success. Not sure if it is the destroying and reinstalling or if the above made it work though. So try both steps and see if that works for you.

ajeema avatar Apr 10 '24 12:04 ajeema

cc: @rbren @xingyaoww

anasdorbani avatar Apr 10 '24 15:04 anasdorbani

If you are still experiencing problems, please try to make sure of this:

Aha, that's exactly the problem: your installation is sending stale information out there, but it's not poetry. We can fix it.

I'm going to reiterate some, but also complete here what I said in other threads on this. So the idea is simple: latest main branch now should work, but we need to get rid of leftover stale information on your environment.

  • stop opendevin backend, frontend, close localhost tabs
  • clear local storage in your browser, or use another browser you haven't used with opendevin in the last few days
  • git pull
  • delete ./cache folder in ./opendevin (important)
  • make build
  • make start-backend, allow it to finish until it says uvicorn ready or so
  • make start-frontend
  • open localhost:3001

enyst avatar Apr 10 '24 18:04 enyst

Hey all--we just merged a possible fix. Try adding SANDBOX_TYPE=exec to your config.toml

rbren avatar Apr 10 '24 21:04 rbren

@rbren this fixed the issue on my side, thanks! (with "exec" around double quotes: SANDBOX_TYPE="exec")

nathsou avatar Apr 10 '24 21:04 nathsou

Hey all--we just merged a possible fix. Try adding SANDBOX_TYPE=exec to your config.toml

Still got error.

Traceback (most recent call last):
  File "/Users/seabornlee/Documents/github/OpenDevin/opendevin/server/agent/manager.py", line 124, in create_controller
    self.controller = AgentController(
                      ^^^^^^^^^^^^^^^^
  File "/Users/seabornlee/Documents/github/OpenDevin/opendevin/controller/agent_controller.py", line 86, in __init__
    self.command_manager = CommandManager(
                           ^^^^^^^^^^^^^^^
  File "/Users/seabornlee/Documents/github/OpenDevin/opendevin/controller/command_manager.py", line 18, in __init__
    self.shell = DockerExecBox(
                 ^^^^^^^^^^^^^^
  File "/Users/seabornlee/Documents/github/OpenDevin/opendevin/sandbox/exec_box.py", line 79, in __init__
    if not self.is_container_running():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/seabornlee/Documents/github/OpenDevin/opendevin/sandbox/exec_box.py", line 192, in is_container_running
    docker_client = docker.from_env()
                    ^^^^^^^^^^^^^^^^^
  File "/Users/seabornlee/Library/Caches/pypoetry/virtualenvs/opendevin-OqOypLLu-py3.12/lib/python3.12/site-packages/docker/client.py", line 94, in from_env
    return cls(
           ^^^^
  File "/Users/seabornlee/Library/Caches/pypoetry/virtualenvs/opendevin-OqOypLLu-py3.12/lib/python3.12/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/seabornlee/Library/Caches/pypoetry/virtualenvs/opendevin-OqOypLLu-py3.12/lib/python3.12/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/seabornlee/Library/Caches/pypoetry/virtualenvs/opendevin-OqOypLLu-py3.12/lib/python3.12/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'))

seabornlee avatar Apr 11 '24 02:04 seabornlee

The SANDBOX_TYPE fix rbren suggested fixes the issue of type:

Pxssh: Could not establish connection to host

The "Error while fetching server API version:" error is different, should probably be in a separate issue. Or better yet, look through earlier issues that report this. There are some troubleshooting steps in earlier issues.

TL;DR, that error means that OpenDevin application is unable to interact with Docker daemon to start a sandbox container. Could be a bunch of reasons, anything from docker is not running to permissions are blocking access.

foragerr avatar Apr 11 '24 03:04 foragerr

Gonna close this as it seems like the original issue is fixed

rbren avatar Apr 12 '24 11:04 rbren