fix: default to unix scheme when DOCKER_HOST is a filesystem path#7060
Open
amarkdotdev wants to merge 2 commits into
Open
fix: default to unix scheme when DOCKER_HOST is a filesystem path#7060amarkdotdev wants to merge 2 commits into
amarkdotdev wants to merge 2 commits into
Conversation
…ze() method in the image formatter used HumanSizeWithPrecision with precision=3, which causes fmt %g to emit scientific notation (1e+03MB) when a size rounds to exactly 1000 in its current unit (e.g. an image of ~999.5 MB). Switch to HumanSize() which uses precision=4 (the standard across the rest of the CLI) and avoids this edge case while still producing compact human-readable output. Fixes docker#3091 Signed-off-by: Aaron <aaroniofjm@gmail.com>
When DOCKER_HOST is set to a filesystem path without a scheme (e.g. /var/run/docker.sock), parseDockerDaemonHost previously defaulted to the "tcp" protocol, producing a confusing error: "Cannot connect to the Docker daemon at tcp://localhost:2375/foo.sock" Now, if the address starts with "/" or "./", the parser defaults to "unix" instead of "tcp", which matches the user's intent and produces a correct connection or a clear error. Fixes docker#5846 Signed-off-by: Aaron <aaroniofjm@gmail.com>
93a9129 to
0d1bf0c
Compare
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
DOCKER_HOSTis set to a filesystem path without aunix://prefix (e.g.DOCKER_HOST=/var/run/docker.sock), the CLI produces a confusing error:The path gets misinterpreted as a TCP address because
parseDockerDaemonHostdefaults to thetcpprotocol when no scheme is present.Root cause
In
opts/hosts.go,parseDockerDaemonHostsplits on://and defaults any scheme-less address totcp:Fix
When the scheme-less address starts with
/or./(i.e. it's clearly a filesystem path), default tounixinstead oftcp. This matches the user's intent and either connects successfully or produces a clear, relevant error.Before:
After:
Testing
TestParseDockerDaemonHostfor/var/run/docker.sockand./run/docker.socktcpand explicitunix://cases remain unchangedFixes #5846