Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`DaemonHost()` returns `http://docker.example.com` for ssh transport

未关闭
#6,164 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
go
领域
cli

调研方向

从 cli/connhelper/connhelper.go 中的 getConnectionHelper 以及 cli/context/docker/load.go 中的客户端主机处理开始。使用 DOCKER_HOST="ssh://user@1.2.3.4" 重现该行为,并跟踪 DaemonHost() 的派生过程。完成的标准是 CLI 能够暴露实际配置的传输方式,包括 ssh、unix 和 pipe,使调用方能够区分远程主机和本地主机。

由索引模型根据 Issue 内容生成。

描述

kind/bug status/0-triage
Description

cli.DaemonHost() gives http://docker.example.com when docker host is set to ssh

the behavior comes from getConnectionHelper in https://github.com/docker/cli/blob/84038691220e7ba3329a177e4e3357b4ee0e3a52/cli/connhelper/connhelper.go#L64 the Host is set to http://docker.example.com in connection helper and later updated the host attribute in the cli.Client at https://github.com/docker/cli/blob/84038691220e7ba3329a177e4e3357b4ee0e3a52/cli/context/docker/load.go#L115

the daemon host is specially useful in docker compose when we want to know if the docker host it's remote or not, like you are doing here https://github.com/docker/cli/blob/84038691220e7ba3329a177e4e3357b4ee0e3a52/cli/context/docker/load.go#L127

Reproduce
DOCKER_HOST="ssh://user@1.2.3.4" docker 
Expected behavior

we should be able to know whenever the docker cli is accessing the docker host via ssh, unix, pipe, etc

basically we should be able to access docker host used

docker version
Client: Docker Engine - Community
 Version:           28.2.2
 API version:       1.50
 Go version:        go1.24.3
 Git commit:        e6534b4
 Built:             Fri May 30 12:07:26 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.2.2
  API version:      1.50 (minimum version 1.24)
  Go version:       go1.24.3
  Git commit:       45873be
  Built:            Fri May 30 12:07:26 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker info
Client: Docker Engine - Community
 Version:    28.2.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.24.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.36.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
Additional Info

No response

主要语言
Go
星标
6.1k
派生
2.2k
平均合并
1 天 10 小时
30 天内合并 PR
47

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/cli 的其他 Issue

查看 docker/cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。