fix: resolve host IP from Docker bridge network for Rancher Desktop compatibility#888
Open
octo-patch wants to merge 1 commit intokatanemo:mainfrom
Open
fix: resolve host IP from Docker bridge network for Rancher Desktop compatibility#888octo-patch wants to merge 1 commit intokatanemo:mainfrom
octo-patch wants to merge 1 commit intokatanemo:mainfrom
Conversation
…ompatibility (fixes katanemo#561) `--add-host host.docker.internal:host-gateway` works on Docker Desktop and standard Docker Engine but not on Rancher Desktop, where the `host-gateway` keyword is not recognised. Introduce `_get_host_ip()` which reads the gateway of the Docker bridge network (e.g. 172.17.0.1) — a portable, concrete IP that works across Docker Desktop, Docker Engine, and Rancher Desktop. If the network inspect fails for any reason the function falls back to `host-gateway`, preserving the existing behaviour for standard installations. Also add unit tests covering the success path, subprocess failure, and empty-output fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #561
Problem
--add-host host.docker.internal:host-gatewayworks on Docker Desktop and standard Docker Engine but not on Rancher Desktop, where thehost-gatewayspecial keyword is not recognised. As a result, the Plano container cannot reach services running on the host machine when started viaplanoai upon Rancher Desktop.Solution
Introduce a
_get_host_ip()helper incli/planoai/docker_cli.pythat reads the gateway IP of the default Docker bridge network (e.g.172.17.0.1) usingdocker network inspect bridge. This is the same IP thathost-gatewayresolves to on standard installations, but uses a concrete address that is universally understood — including by Rancher Desktop.If the network inspect fails for any reason (Docker not running, custom network setup, etc.) the function falls back to
host-gateway, preserving backward compatibility.Testing
cli/test/test_docker_cli.pycovering:host-gatewayon subprocess failurehost-gatewayon empty outputuv run pytest test/test_docker_cli.py)