Skip to content

fix: support Docker daemon over SSH (DOCKER_HOST=ssh://...)#3078

Open
lucklove wants to merge 1 commit into
replicate:mainfrom
lucklove:main
Open

fix: support Docker daemon over SSH (DOCKER_HOST=ssh://...)#3078
lucklove wants to merge 1 commit into
replicate:mainfrom
lucklove:main

Conversation

@lucklove

Copy link
Copy Markdown

Problem

When DOCKER_HOST or the active Docker context is set to an SSH endpoint (e.g. ssh://user@host), cog fails with:

error pinging docker daemon: error during connect: Head "http://user@host/_ping": dial tcp: lookup user@host: no such host

The root cause is that the Docker Go SDK's client.WithHost() does not understand the ssh:// scheme — it attempts a plain TCP/HTTP connection instead of tunneling over SSH.

The standard docker CLI handles this transparently via connhelper.GetConnectionHelper(), which returns an SSH-based dialer for ssh:// hosts.

Fix

After building the dockerClientOpts slice, call connhelper.GetConnectionHelper(host). If the host is an SSH URL, inject the returned SSH dialer via client.WithDialContext. This mirrors how the official Docker CLI handles remote SSH daemons.

if helper, err := connhelper.GetConnectionHelper(clientOptions.host); err == nil && helper != nil {
    dockerClientOpts = append(dockerClientOpts, client.WithDialContext(helper.Dialer))
}

github.com/docker/cli is already a dependency, so no new dependencies are introduced.

Testing

  • Existing pkg/docker tests all pass
  • Manually verified cog build works against a remote Docker daemon via DOCKER_HOST=ssh://root@<host>

@lucklove lucklove requested a review from a team as a code owner June 27, 2026 11:58
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.

1 participant