Skip to content

Conversation

@doringeman
Copy link
Contributor

Fixes #653.

To test this, checkout this PR and install the CLI:

make -C cmd/cli install

E.g.,

$ docker -H ssh://testuser@localhost:2222 model run smollm2 hi
Hello, I am Hugging Face and I can assist you with your requests. What do you need help with today?

Fixes docker#653.

Signed-off-by: Dorin Geman <dorin.geman@docker.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 -H flag, greatly improving the flexibility and reach of CLI operations without requiring direct local daemon access. The change primarily involves updating the Docker client initialization to incorporate SSH connection helpers.

Highlights

  • SSH Remote Host Support: Implemented support for connecting to Docker daemons over SSH using the -H flag, allowing CLI commands to interact with remote hosts.
  • Docker CLI Integration: Integrated github.com/docker/cli/cli/connhelper to facilitate SSH connection handling within the DockerClientForContext function.

🧠 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
  • cmd/cli/desktop/context.go
    • Added import for github.com/docker/cli/cli/connhelper to enable SSH connection functionality.
    • Modified the DockerClientForContext function to dynamically configure the Docker client with SSH connection options (WithHost and WithDialContext) when an SSH host is detected via connhelper.GetConnectionHelper.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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.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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +88 to +103
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),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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))
}

Copy link
Contributor

@ericcurtin ericcurtin left a 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

@blackblather
Copy link

blackblather commented Feb 11, 2026

Hi,

I tested your changes and when running docker -H ssh://blackblather:192.168.1.151 model list that error is gone.

Now I do face a different error:

docker -H ssh://blackblather:192.168.1.151 model list

latest: Pulling from docker/model-runner
608c81a99d0f: Download complete
723ca77ac84e: Download complete
Digest: sha256:887f073f3a753e647df2c17fcc83487b1356d3ceab113832bc18a9d75123bf33
Status: Downloaded newer image for docker/model-runner:latest
Successfully pulled docker/model-runner:latest
Starting model runner container docker-model-runner...
unable to initialize standalone model runner: unable to initialize standalone model runner container: failed to start container docker-model-runner: Error response from daemon: ports are not available: exposing port TCP 172.17.0.1:12434 -> 127.0.0.1:0: listen tcp4 172.17.0.1:12434: bind: can't assign requested address

I think this issue is no longer related to the original SSH issue.
I say this because I tried using a "direct TCP connection" to the remote server, like this:

  • socat TCP-LISTEN:2376,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock (on the remote machine)
  • docker -H 192.168.1.151:2376 model list (on the client machine)

and the same behavior happens.

It pulls the docker/model-runner docker image on the remote machine, but cannot start it.
I did notice in the DockerHub link for this image it mentions: These images aren't currently intended for direct use by end-users.

However, I did try to run this image directly in the mac to see what happens, using docker run -p 12434:12434 docker/model-runner, and it prints:

time="2026-02-11T21:10:27Z" level=info msg="Successfully initialized store" component=model-manager
time="2026-02-11T21:10:27Z" level=info msg="LLAMA_SERVER_PATH: /app/bin"
time="2026-02-11T21:10:27Z" level=info msg="Metrics endpoint enabled at /metrics"
time="2026-02-11T21:10:27Z" level=info msg="Listening on TCP port 12434" 👈
time="2026-02-11T21:10:27Z" level=warning msg="Backend installation failed for sglang: python3 not found in PATH"
time="2026-02-11T21:10:27Z" level=warning msg="Backend installation failed for diffusers: python3 not found in PATH"
time="2026-02-11T21:10:27Z" level=warning msg="Backend installation failed for vllm: vLLM binary not found"
time="2026-02-11T21:10:27Z" level=info msg="failed to ensure latest llama.cpp: llama.cpp auto-updated is disabled\n"
time="2026-02-11T21:10:27Z" level=info msg="installed llama-server with gpuSupport=false" 👈
time="2026-02-11T21:10:27Z" level=warning msg="Backend installation failed for mlx: MLX is only available on macOS ARM64"

I still only have surface level understanding on technical inner workings of docker, so I have some follow-up questions.

  • Why does this happen:
    • docker -H ssh://blackblather:192.168.1.151 model list (from the client machine)
      • 🛑 docker complains that port 12434 is occupied
    • docker run -p 12434:12434 docker/model-runner (from the remote machine)
      • ✅ docker doesn't complain anymore (wasn't this port "supposed" to be occupied?)

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:

  • why is it trying to download DMR as a container running in a VM, if that VM has no GPU access (as the logs above seem to suggest: installed llama-server with gpuSupport=false)?

Thank you again, maybe this discussion is no longer relevant in this PR 👍

@ericcurtin
Copy link
Contributor

Merging this and debugging the follow on issue makes sense

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker model runner cannot be used with -H flag to connect to remote server

3 participants