git克隆无法到达docker容器内的主机
这个问题我很久以前就遇到了,根本解决不了。谁能给我一些帮助吗 我创建了一个docker容器,然后在docker内部,我想克隆一个内部git存储库:git克隆无法到达docker容器内的主机,git,ssh,docker,git-clone,Git,Ssh,Docker,Git Clone,这个问题我很久以前就遇到了,根本解决不了。谁能给我一些帮助吗 我创建了一个docker容器,然后在docker内部,我想克隆一个内部git存储库: git clone git@git.xxx.net:ngcsc/ngcsc.git 我得到了这个错误: ssh: connect to host git.xxx.net port 22: No route to host fatal: Could not read from remote repository. Please make sure
git clone git@git.xxx.net:ngcsc/ngcsc.git
我得到了这个错误:
ssh: connect to host git.xxx.net port 22: No route to host
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
如果我使用curl,
我也遇到了错误:
curl: (7) Failed connect to git.xxx.net:443; No route to host
我可以卷曲其他https网站,如卷曲
我不知道为什么有些内部网站可以在docker内部访问,有些则不能。非常感谢您的任何建议我想既然您正在使用git clone的ssh url,那么您应该生成一个ssh密钥并在git门户上注册它 然后您必须在docker容器中包含ssh密钥,并执行
ssh add keyfile
希望这能解决您的问题首先,确保在启动容器时已映射了相关端口,通常ssh使用port
22
或443
,这样您就可以简单地映射这两个端口
docker run -it -p 22:22 -p 443:443 IMAGE_ID
其次,在docker内部,您应该生成一个ssh密钥对,并注册您正在使用的git门户。只需使用命令
ssh-keygen
即可生成新的密钥对。可能与此相关:我猜我使用的AWS实例不允许传出ssh,使用HTTPS修复了我的问题