mirror of
https://github.com/usestrix/strix.git
synced 2026-10-05 02:41:38 +00:00
fix(docker): use the current docker context only, no DOCKER_CONTEXT override
This commit is contained in:
parent
172246b5db
commit
828462cfc9
3 changed files with 2 additions and 22 deletions
|
|
@ -150,11 +150,7 @@ When remote vars are set, Strix dual-writes telemetry to both local JSONL and th
|
|||
</ParamField>
|
||||
|
||||
<ParamField path="DOCKER_HOST" type="string">
|
||||
Docker daemon address, for example `unix:///var/run/docker.sock` or `tcp://10.0.0.5:2375`. When set, Strix uses it and ignores the docker context.
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="DOCKER_CONTEXT" type="string">
|
||||
Docker context to use. Strix connects to the same daemon as the `docker` CLI: `DOCKER_HOST` first, then this context, then the current context from `docker context use`, then the default socket. Docker Desktop, OrbStack and Colima register their sockets as contexts, so no extra configuration is needed for them.
|
||||
Docker daemon address, for example `unix:///var/run/docker.sock` or `tcp://10.0.0.5:2375`. When not set, Strix connects to the same daemon as the `docker` CLI: the current docker context (`docker context use`), then the default socket. Docker Desktop, OrbStack and Colima register their sockets as contexts, so no extra configuration is needed for them.
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="STRIX_RUNTIME_BACKEND" default="docker" type="string">
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ def resolve_docker_endpoint(environ: dict[str, str] | None = None) -> DockerEndp
|
|||
if host:
|
||||
return DockerEndpoint(host, "DOCKER_HOST")
|
||||
|
||||
name = env.get("DOCKER_CONTEXT", "").strip() or get_current_context_name()
|
||||
name = get_current_context_name()
|
||||
if name != DEFAULT_CONTEXT:
|
||||
try:
|
||||
context = ContextAPI.get_context(name)
|
||||
|
|
|
|||
|
|
@ -51,22 +51,6 @@ def test_current_context_is_used_like_the_cli(monkeypatch: pytest.MonkeyPatch) -
|
|||
assert endpoint.source == "docker context 'desktop-linux'"
|
||||
|
||||
|
||||
def test_docker_context_env_overrides_the_config_file(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(docker_connection, "get_current_context_name", lambda: "default")
|
||||
seen: list[str] = []
|
||||
|
||||
def get_context(name: str) -> SimpleNamespace:
|
||||
seen.append(name)
|
||||
return SimpleNamespace(Host="unix:///run/orbstack.sock", TLSConfig=None)
|
||||
|
||||
monkeypatch.setattr("strix.runtime.docker_connection.ContextAPI.get_context", get_context)
|
||||
assert (
|
||||
resolve_docker_endpoint({"DOCKER_CONTEXT": "orbstack"}).source
|
||||
== "docker context 'orbstack'"
|
||||
)
|
||||
assert seen == ["orbstack"]
|
||||
|
||||
|
||||
def test_default_and_broken_contexts_fall_back_to_the_sdk(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(docker_connection, "get_current_context_name", lambda: "default")
|
||||
assert resolve_docker_endpoint({}) == DockerEndpoint(None, "default socket")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue