-
Notifications
You must be signed in to change notification settings - Fork 94
feat: add SSH remote host support via -H flag #658
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
base: main
Are you sure you want to change the base?
Conversation
Fixes docker#653. Signed-off-by: Dorin Geman <dorin.geman@docker.com>
Summary of ChangesHello @doringeman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant feature by enabling the CLI to connect to remote Docker daemons via SSH. This enhancement allows users to specify an SSH host using the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Hey - I've left some high level feedback:
- Calling
connhelper.GetConnectionHelperunconditionally means a non-SSH host thatconnhelperdoesn’t recognize will now fail; consider guarding this call (e.g., only forssh://schemes) or falling back to the plain host when an error is returned. - The error message
"unable to get SSH connection helper"is used even when the host is not SSH-based; consider either narrowing when this error is produced or using a more generic message to avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Calling `connhelper.GetConnectionHelper` unconditionally means a non-SSH host that `connhelper` doesn’t recognize will now fail; consider guarding this call (e.g., only for `ssh://` schemes) or falling back to the plain host when an error is returned.
- The error message `"unable to get SSH connection helper"` is used even when the host is not SSH-based; consider either narrowing when this error is produced or using a more generic message to avoid confusion.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Code Review
This pull request adds support for connecting to a remote Docker host via SSH using the -H flag. The implementation correctly uses connhelper to establish the connection. I've suggested a small refactoring to improve code clarity by avoiding a redundant client option.
| opts := []clientpkg.Opt{ | ||
| clientpkg.FromEnv, | ||
| clientpkg.WithHost(endpoint.Host), | ||
| clientpkg.WithAPIVersionNegotiation(), | ||
| ) | ||
| clientpkg.WithHost(endpoint.Host), | ||
| } | ||
|
|
||
| helper, err := connhelper.GetConnectionHelper(endpoint.Host) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("unable to get SSH connection helper: %w", err) | ||
| } | ||
| if helper != nil { | ||
| opts = append(opts, | ||
| clientpkg.WithHost(helper.Host), | ||
| clientpkg.WithDialContext(helper.Dialer), | ||
| ) | ||
| } |
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.
The clientpkg.WithHost option is being set unconditionally with endpoint.Host and then potentially overridden if an SSH connection helper is found. This is redundant and can be confusing. It's cleaner to determine the correct host first and then set the WithHost option only once, which is a common pattern in docker/cli.
| opts := []clientpkg.Opt{ | |
| clientpkg.FromEnv, | |
| clientpkg.WithHost(endpoint.Host), | |
| clientpkg.WithAPIVersionNegotiation(), | |
| ) | |
| clientpkg.WithHost(endpoint.Host), | |
| } | |
| helper, err := connhelper.GetConnectionHelper(endpoint.Host) | |
| if err != nil { | |
| return nil, fmt.Errorf("unable to get SSH connection helper: %w", err) | |
| } | |
| if helper != nil { | |
| opts = append(opts, | |
| clientpkg.WithHost(helper.Host), | |
| clientpkg.WithDialContext(helper.Dialer), | |
| ) | |
| } | |
| opts := []clientpkg.Opt{ | |
| clientpkg.FromEnv, | |
| clientpkg.WithAPIVersionNegotiation(), | |
| } | |
| helper, err := connhelper.GetConnectionHelper(endpoint.Host) | |
| if err != nil { | |
| return nil, fmt.Errorf("unable to get SSH connection helper: %w", err) | |
| } | |
| if helper != nil { | |
| opts = append(opts, | |
| clientpkg.WithHost(helper.Host), | |
| clientpkg.WithDialContext(helper.Dialer), | |
| ) | |
| } else { | |
| opts = append(opts, clientpkg.WithHost(endpoint.Host)) | |
| } |
ericcurtin
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.
Nice, that was fast
|
Hi, I tested your changes and when running Now I do face a different error:
I think this issue is no longer related to the original SSH issue.
and the same behavior happens. It pulls the However, I did try to run this image directly in the mac to see what happens, using I still only have surface level understanding on technical inner workings of docker, so I have some follow-up questions.
Lastly, AFAIK, the docker daemon in Mac OS runs in a VM created using the Apple Virtualization Framework (AVF), but Apple doesn't provide GPU access to VMs created using AVF That's why when using Docker Desktop, Docker Model Runner (DMR) will run directly on the host. If my understanding is correct:
Thank you again, maybe this discussion is no longer relevant in this PR 👍 |
|
Merging this and debugging the follow on issue makes sense |
Fixes #653.
To test this, checkout this PR and install the CLI:
E.g.,