【问题标题】:"ssh: Could not resolve hostname github.com: Try again" - Inside docker container“ssh:无法解析主机名 github.com:再试一次” - 在 docker 容器内
【发布时间】:2018-07-09 14:19:42
【问题描述】:

我遇到了这样一个奇怪的问题。我需要在刚刚创建的侧容器中启动一个容器并通过 ssh 克隆 github 项目。有时 git clone 完美,而且没有任何麻烦。但有时它不能这样说:

ssh: Could not resolve hostname github.com: Try again
fatal: Could not read from remote repository.

我尝试了很多方法,例如通过添加 google DNS 更改 mys /etc/resolv.conf,将 google DNS 回显到容器内的 /etc/resolv.conf,重新启动 docker,重新安装 docker 但没有运气..
我的 git clone 容器加入了一个 docker 用户定义桥接网络。我认为网络是我的问题之一,但我不知道到底发生了什么。
另一个通知,如果我在本地运行它一切正常 - ubuntu os。问题只发生在我的 Linode 服务
有没有人遇到这个问题?请帮帮我...

【问题讨论】:

  • 对于搜索此问题的人。我使用了 CentOS 服务器。只需使用 Ubuntu,问题就消失了。

标签: git docker ssh dockerfile docker-machine


【解决方案1】:

如果您使用的是lish shell session,请尝试使用suggested here

ssh -Tvvv git@github.com

然后执行traceroute 以查看解析失败的位置。

【讨论】:

  • 感谢您的回复,我已经尝试过以这种方式调试连接,并且当时它挂起连接到 github...无法得到任何响应或错误警告...
  • @TruongDang 你有~/.ssh/config 文件吗?
  • 是的。这是我为我的 docker iamge 所做的。它在本地机器上运行良好echo -e "Host *\n\tStrictHostKeyChecking no\n\tIdentityFile /root/.ssh/id_rsa\n\tAddKeysToAgent yes\n" > /root/.ssh/config
  • @TruongDang 您的私人 SSH 密钥密码受到保护吗?
  • @TruongDang OK 所以在 Linode 端可能不需要 AddKeysToAgent。 ping github.com 是否有效(来自 Linode)?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-30
  • 1970-01-01
  • 1970-01-01
  • 2015-02-27
  • 1970-01-01
  • 2017-04-12
相关资源
最近更新 更多