Resolve default endpoint from docker CLI context#603
Open
ebriney wants to merge 4 commits into
Open
Conversation
Match docker CLI lookup when neither DOCKER_URL nor DOCKER_HOST is set: read DOCKER_CONTEXT (or currentContext from $DOCKER_CONFIG/config.json, defaulting to ~/.docker/config.json) and pull Endpoints.docker.Host from the context's meta.json. Falls back to the default unix socket when no context is configured, the context is named "default", or any file is missing or unparseable. Set DOCKER_API_SKIP_CONTEXT=1 to disable. TLS material is still sourced from DOCKER_CERT_PATH; only the endpoint URL is read from the context. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Explain the DOCKER_URL → DOCKER_HOST → docker CLI context → default socket lookup, the DOCKER_CONFIG / DOCKER_CONTEXT overrides, and the DOCKER_API_SKIP_CONTEXT kill switch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Recognize the npipe:// URL scheme so docker-api can talk to the Docker engine over a Windows named pipe. Docker::Connection parses npipe:// URLs into a :socket path, lazy-loads a small Excon::Connection patch that dispatches the scheme to a Docker::NPipeSocket, and the socket itself opens the pipe through CreateFile/ReadFile/WriteFile via ffi. Also defaults the endpoint to npipe:////./pipe/docker_engine on Windows when neither DOCKER_URL/DOCKER_HOST nor a docker CLI context resolves an endpoint -- matching the docker CLI default on that platform. The ffi dependency is only loaded when an npipe URL is actually used, so non-Windows users pay no runtime cost. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Note the platform-conditional default endpoint and the npipe:// URL form callers can use to point at a custom pipe. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Make
Docker.urlmirror thedockerCLI when neitherDOCKER_URLnorDOCKER_HOSTis set: read the current context from$DOCKER_CONFIG/config.json(default~/.docker/config.json) and pullEndpoints.docker.Hostfrom the context'smeta.json. Falls back tounix:///var/run/docker.sockwhen no usable context is found.Resolution order is now:
DOCKER_URLDOCKER_HOSTDOCKER_CONTEXTenv, otherwisecurrentContextfromconfig.jsonunix:///var/run/docker.sockThis means users with Docker Desktop, Colima, OrbStack, rootless setups, etc. — which all install their endpoint under a non-default context — no longer need to manually export
DOCKER_HOSTfor the gem to find the daemon.Notes
DOCKER_API_SKIP_CONTEXT=1disables step 3 and restores the previous behavior (env vars + default socket only).DOCKER_CERT_PATH/DOCKER_SSL_VERIFY(unchanged). Per-context TLS material could be a follow-up if there's demand.defaultall cleanly fall through to the next step — a broken config never raises fromDocker.url.DOCKER_CONFIGenv var is honored.Test plan
spec/docker_spec.rbcover:currentContextlookup,DOCKER_CONTEXToverride, thedefaultcontext, missing config.json, missing meta.json, env precedence over context, and the kill switch.~/.docker/config.json).Docker.url,Docker.version, andDocker.infomatchdocker infoexactly (same endpointunix:///Users/.../docker/run/docker.sock, same Server Version / OS / Name / container/image counts).🤖 Generated with Claude Code