Open
Description
Description
$ DOCKER_HOST=/invalid.sock docker version
Client:
Version: 27.5.1
API version: 1.47
Go version: go1.22.11
Git commit: 9f9e405
Built: Wed Jan 22 13:39:08 2025
OS/Arch: linux/arm64
Context: default
Cannot connect to the Docker daemon at tcp://localhost:2375/invalid.sock. Is the docker daemon running?
This error message is quite confusing, as the original invalid DOCKER_HOST
value does not contain tcp://localhost:2375
.
Probably it should return an error like invalid $DOCKER_HOST value "/invalid.sock": must start with "unix://" or "tcp://"
Activity
thaJeztah commentedon Feb 20, 2025
Thx! Yeah, I think there's some dubious (and inconsistent) handling for these in some areas.
I suspect I may have introduced this when I replaced some code with
url.Parse
(adding a scheme if missing), but it's possible it was elsewhere as I found multiple places where logic for this was implemented, but ever-so-slightly different.thaJeztah commentedon Feb 20, 2025
Oh, and if we're gonna add that to the error message,
ssh://
should probably also be there.I suspect part of this may be due to logic where
hostname
(without scheme) would be consideredtcp://hostname
, and we may be usingtcp
as default if not set, which in this case, gets seen as<host missing>/invalid.sock
-><default host and scheme>/invalid.sock
.But perhaps in this case, we should consider checking if the value starts with something that indicates a path (
/
,./
), as in that case the user very likely meant "path to a socket".ZayaanRahman commentedon Apr 6, 2025
Hi! I'm interested in contributing to the Docker cli, and was wondering if this was a good issue I could get started on.