Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cli/connhelper/connhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ func getConnectionHelper(daemonURL string, sshFlags []string) (*ConnectionHelper
}
return &ConnectionHelper{
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
return commandconn.New(ctx, "ssh", append(sshFlags, sp.Args("docker", "system", "dial-stdio")...)...)
args := []string{"docker"}
if sp.Path != "" {
args = append(args, "--host", "unix://"+sp.Path)
}
args = append(args, "system", "dial-stdio")
return commandconn.New(ctx, "ssh", append(sshFlags, sp.Args(args...)...)...)
},
Host: "http://docker.example.com",
}, nil
Expand Down
5 changes: 2 additions & 3 deletions cli/connhelper/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ func ParseURL(daemonURL string) (*Spec, error) {
return nil, errors.Errorf("no host specified")
}
sp.Port = u.Port()
if u.Path != "" {
return nil, errors.Errorf("extra path after the host: %q", u.Path)
}
sp.Path = u.Path
if u.RawQuery != "" {
return nil, errors.Errorf("extra query after the host: %q", u.RawQuery)
}
Expand All @@ -47,6 +45,7 @@ type Spec struct {
User string
Host string
Port string
Path string
}

// Args returns args except "ssh" itself combined with optional additional command args
Expand Down
6 changes: 4 additions & 2 deletions cli/connhelper/ssh/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ func TestParseURL(t *testing.T) {
expectedError: "plain-text password is not supported",
},
{
url: "ssh://foo/bar",
expectedError: `extra path after the host: "/bar"`,
url: "ssh://foo/bar",
expectedArgs: []string{
"--", "foo",
},
},
{
url: "ssh://foo?bar",
Expand Down
1 change: 1 addition & 0 deletions docs/reference/commandline/dockerd.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ precedence over `HTTP_PROXY`.
The Docker client supports connecting to a remote daemon via SSH:

```console
$ docker -H ssh://me@example.com:22/var/run/docker.sock ps
$ docker -H ssh://me@example.com:22 ps
$ docker -H ssh://me@example.com ps
$ docker -H ssh://example.com ps
Expand Down