我已经设置了 docker 工具箱并安装了 gitlab-ce 来测试 gitlab 持续集成功能,我能够连接到 gitlab 实例并创建一个存储库,创建一个新的 ssh key 并将其粘贴到存储库上。
但问题是当我试图推送到这个存储库时,它给了我这个错误:
ssh: Could not resolve hostname c52795c5acda: Name or service not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
git url 如下:
git@c52795c5acda:root/my-project.git
我替换了 c52795c5acda 使用容器 ip 地址和端口,并且似乎使用 HTTPS 但不使用 ssh。
我的系统是 Windows 8.1,我在虚拟机上运行 docker。谁能指出这个问题?
最佳答案
姓名c52795c5acd
是 docker 为您的容器提供的随机主机名。它可能会发生变化,IP 地址也是如此。
最简单的解决方案是使用 -p
将 docker 主机的端口映射到 docker 容器。选项。然后你可以在你的 git url 中使用你的 docker 主机名。
您还需要为 gitlab 配置外部 URL,请参见此处:http://docs.gitlab.com/omnibus/settings/configuration.html
关于git - ssh:无法解析主机名(Docker、gitlab-ce),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39103237/