fix(publish): bypass Docker Desktop proxy for localhost/insecure registries#13825
Open
ptrdom wants to merge 2 commits into
Open
fix(publish): bypass Docker Desktop proxy for localhost/insecure registries#13825ptrdom wants to merge 2 commits into
ptrdom wants to merge 2 commits into
Conversation
…stries compose publish routed all registry traffic through Docker Desktop's HTTP proxy, so publishing to a localhost/insecure registry failed on Windows with "proxyconnect tcp: open ./pipe/dockerHttpProxy: The system cannot find the path specified", while docker push/pull worked against the same registry. Two bugs in internal/desktop/proxy.go: - ProxyTransport forced every request through the DD proxy and its DialContext always dialed the proxy socket, so loopback targets could never connect directly. Select the proxy via httpproxy.Config.ProxyFunc, which exempts localhost/loopback and now also honors NO_PROXY; route only the sentinel proxy address to the DD socket and dial real targets directly otherwise. - The Windows named-pipe endpoint was hardcoded as npipe://./pipe/..., yielding the relative path ./pipe/dockerHttpProxy. Derive it from the engine endpoint, preserving the dialable npipe:////./pipe/ prefix. Fixes docker#13824 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Domantas Petrauskas <dom.petrauskas@gmail.com>
End-to-end validation against Docker Desktop 29.5.2 showed it reports its engine endpoint as `npipe://\.\pipe\docker_cli` (backslash namespace), not the forward-slash form assumed earlier. LastIndex(endpoint, "/") then matched the slash in "npipe://" and produced `npipe://dockerHttpProxy`, dropping the `\.\pipe\` namespace. Use LastIndexAny(endpoint, `/\`) so both the backslash form Docker Desktop actually reports and the forward-slash form resolve to a dialable pipe path. Verified the published artifact lands in a localhost registry and that the parent commit still reproduces the original "proxyconnect tcp: open ./pipe/dockerHttpProxy" failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Domantas Petrauskas <dom.petrauskas@gmail.com>
Author
|
I have also manually tested this on MacOS (M1 Mac) with Docker Desktop, managed to reproduce the issue and confirmed that this PR fixes it. |
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.
What I did
docker compose publishrouted all registry traffic through Docker Desktop's HTTP proxy. Publishing to a localhost/insecure registry therefore failed on Windows with:even though
docker push/docker pullworked against the same registry.Two bugs in
internal/desktop/proxy.go:ProxyTransportforced every request through the DD proxy and itsDialContextalways dialed the proxy socket, so loopback targets could never connect directly. Proxy selection now goes throughhttpproxy.Config.ProxyFunc, which exemptslocalhost/loopback and additionally honorsNO_PROXY.DialContextroutes only the sentinel proxy address to the DD socket and dials real targets directly otherwise.npipe://./pipe/..., yielding the relative path./pipe/dockerHttpProxy. It is now derived from the engine endpoint, preserving its namespace. Docker Desktop reports the endpoint in the backslash formnpipe://\\.\pipe\docker_cli, so the derivation usesLastIndexAnyto handle both backslash and forward-slash forms.Result: publishing to
localhost:5000connects directly likedocker push, while the DD proxy still serves external registries (now reachable on Windows).Related issue
Fixes #13824
How I tested
Validated end-to-end on Docker Desktop 29.5.2 / Windows 11 (the issue's environment) by building binaries from both the parent commit and this branch and running the issue's reproduction steps:
proxyconnect tcp: open ./pipe/dockerHttpProxy: The system cannot find the path specified.(exit 1).Automated coverage in
internal/desktop/proxy_test.go:TestDDProxyFunc_BypassesLoopbackAndHonorsNoProxy— loopback names/IPs andNO_PROXYhosts bypass; external hosts proxy.TestHTTPProxySocketEndpoint_WindowsNamedPipe— proxy pipe path keeps the engine endpoint's namespace for both backslash and forward-slash forms.🤖 Generated with Claude Code