Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCKER_HOST without unix:// prefix prints a confusing error: Cannot connect to the Docker daemon at tcp://localhost:2375/foo.sock. #5846

Open
AkihiroSuda opened this issue Feb 20, 2025 · 2 comments

Comments

@AkihiroSuda
Copy link
Collaborator

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://"

@thaJeztah
Copy link
Member

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
Copy link
Member

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 considered tcp://hostname, and we may be using tcp 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants