-
Notifications
You must be signed in to change notification settings - Fork 2.1k
connhelper: Allow socket path when using SSH #4073
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
Conversation
|
alternative impl, since case "ssh":
sp, err := ssh.ParseURL(daemonURL)
if err != nil {
return nil, errors.Wrap(err, "ssh host connection is not valid")
}
return &ConnectionHelper{
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
args := []string{"docker"}
if sp.Path != "" {
args = append(args, "--host", fmt.Sprintf("unix://%s", sp.Path))
}
args = append(args, "system", "dial-stdio")
return commandconn.New(ctx, "ssh", append(sshFlags, sp.Args(args...)...)...)
},
Host: "http://docker.example.com",
}, nil
} |
|
Do you have a specific use-case for this? IIUC, the current design was for the remote CLI to already be configured to connect to a specific socket location ( |
|
I didn't knew it could be set in config but that would not help if I have multiple daemons running on the remote host, since I would have to change the config each time before connecting. |
Basically, yes. |
|
I'm also skeptical of this method and the format. Giving a special meaning to the colon character is not great (and do we already support |
neersighted
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a closer look at this diff, and this is a lot more palatable now that I see this is not in fact a microformat, but instead simply using standard URL parsing logic ala Git. user@host:port/path/to/docker.sock will work, as will user@host:/path/to/docker.sock.
However, I think that Args definitely needs refactoring. It now only works in terms of the docker CLI, and hardcodes knowledge that the path to the CLI will be the first field of add. That should become more generic (or maybe we should set DOCKER_HOST instead as SSH always invokes a shell) to make this maintainable.
This has been a well established format for all tools that are based on SSH ( |
I would be glad to leave that work for whoever has better understanding of whole codebase and vision for the feature (and more time to do it). |
|
Yes, your examples have a null port ( |
Sorry, it's my unfortunate habit if typing the URI :) |
467dd2f to
8540142
Compare
Signed-off-by: Jakub Panek <me@panekj.dev>
8540142 to
25ebf0e
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@neersighted @laurazard LGTY?
- "connhelper: Allow socket path when using SSH"
- What I did
Modified
connhelperto allow socket path in SSH URI- How I did it
Removed error if path is specified when using
ssh://schemeAdded capture of URI Path
Append
--hostflag with formatted socket path asunix://%sbetween passed args- How to verify it
Run below
Linux/macOS:
DOCKER_HOST='ssh://host/var/run/docker.sock' docker system infoWindows
- Description for the changelog
Allow specifying socket path when connecting via SSH
- A picture of a cute animal (not mandatory but encouraged)
