All-Hands-AI / OpenHands

🙌 OpenHands: Code Less, Make More
https://all-hands.dev
MIT License
31.25k stars 3.6k forks source link

Container-to-Host Communication Issue #2692

Closed PierrunoYT closed 1 day ago

PierrunoYT commented 2 months ago

Container-to-Host Communication Issue

What problem or use case are you trying to solve?

The problem is enabling communication between a containerized application and a service running on the host machine.

Describe the UX of the solution you'd like

The ideal solution would allow the containerized application to seamlessly access and interact with the service running on the host machine, as if they were on the same network.

Do you have thoughts on the technical implementation?

The current implementation involves running a web application on the host machine's localhost on a specific port. The application is started using a command that runs the server in the background and logs output to a file. Specifically, Docker networking needs to be configured to allow the container to communicate with the host's localhost.

  1. Network Configuration:

    • Ensure that Docker is correctly configured to allow communication with the host machine using --add-host host.docker.internal:host-gateway.
  2. Environment Variables:

    • Set relevant environment variables to configure the frontend and backend components to communicate over the correct network paths.
  3. Docker Run Command:

    • Utilize the following docker run command to ensure proper networking setup:

      docker run -it \
       --pull=always \
       -e SANDBOX_USER_ID=$(id -u) \
       -e WORKSPACE_MOUNT_PATH=$(pwd)/workspace \
       -v $(pwd)/workspace:/opt/workspace_base \
       -v /var/run/docker.sock:/var/run/docker.sock \
       -p 3000:3000 \
       --add-host host.docker.internal:host-gateway \
       --name opendevin-app-$(date +%Y%m%d%H%M%S) \
       ghcr.io/opendevin/opendevin:0.6.2
  4. Sandbox Configuration:

    • Ensure the config.toml file correctly specifies the sandbox type and settings, such as ssh or exec for Docker.

Describe alternatives you've considered

  1. Using Host Networking Mode:

    • Explore Docker's --network="host" mode if applicable, though it might introduce security considerations and is not supported on all operating systems.
  2. Reverse Proxy Setup:

    • Implementing a reverse proxy on the host machine to forward requests from the containerized application to the local service.

Additional context

haddadnidal commented 2 months ago

f you are encountering any problem regarding Ollama and opendevin docker image issue and you are on linux, just edit ollama service and add Environment="OLLAMA_ORIGINS=*" this is the article. This will make Ollama instance availble outside the localhost of the machine. https://medium.com/dcoderai/how-to-handle-cors-settings-in-ollama-a-comprehensive-guide-ee2a5a1beef0

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

PierrunoYT commented 1 month ago

Any updates?

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 day ago

This issue was closed because it has been stalled for over 30 days with no activity.