connhelper: include ssh remote host in dummy client URL (fixes #5604) - #7229
Open
adisivaprasad wants to merge 1 commit into
Open
connhelper: include ssh remote host in dummy client URL (fixes #5604)#7229adisivaprasad wants to merge 1 commit into
adisivaprasad wants to merge 1 commit into
Conversation
When connecting to a daemon over ssh, ConnectionHelper.Host is used as a dummy URL for the API client, since Go's stdlib requires a valid hostname in requests. This dummy URL (http://docker.example.com) also showed up in connection error messages, which made users believe the CLI was trying to connect to docker.example.com instead of the remote host they configured: Error: Cannot connect to the Docker daemon at http://docker.example.com. Use the ssh target's hostname (and non-default port) in the dummy URL so that connection errors point at the host the user configured, e.g.: Error: Cannot connect to the Docker daemon at http://myserver.local. The URL remains a dummy; the actual connection is established via the ssh dialer, so this does not change how requests are transported. Fixes: docker#5604 Signed-off-by: adisivaprasad <adisivaprasad@users.noreply.github.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.
Description
When connecting to a daemon over
ssh://,ConnectionHelper.Hostis used as a dummy URL for the API client (Go's stdlib requires a valid hostname in requests). That dummy value —http://docker.example.com— also ends up in connection error messages, so a failed connection reports:which makes users believe the client is trying to connect to
docker.example.cominstead of the remote host they configured. This was reported in #5604; as suggested there, this change makes the error mention the hostname the user actually provided.What this changes
For ssh connections, the dummy URL now embeds the remote hostname (and the port, when non-default), so the error reads e.g.:
The URL remains a pure dummy: the actual connection is established through the ssh
Dialer(docker system dial-stdioover ssh), so request transport behavior is unchanged. Command-based connection helpers (GetCommandConnectionHelper) keep the generic dummy host since there is no meaningful hostname to surface.Tests
Added
TestConnectionHelperHostIncludesRemoteHostcovering plain/user+host/custom-port/explicit-default-port ssh URLs, andTestGetCommandConnectionHelperHostpinning the generic dummy for command-based helpers.go test ./cli/connhelper/...passes.AI assistance disclosure
This change was implemented with assistance from an AI coding agent (design direction informed by the discussion in #5604); the resulting code has been reviewed for correctness and follows the existing style of the package.
Changelog
A picture of a cute animal (not mandatory but encouraged)