docker git clone public仓库时出错

新手上路,请多包涵

1. dockerfile 中 git clone 时,发现即便是public的仓库,也会出错

2. 下面是我用GIT_CURL_VERBOSE=1 输出git clone的日志

Step 12/16 : RUN GIT_CURL_VERBOSE=1 git clone https://github.com/aijm/BSplineSurface.git
 ---> Running in acb027444855
Cloning into 'BSplineSurface'...
* Couldn't find host github.com in the .netrc file; using defaults
*   Trying 13.250.177.223...
* TCP_NODELAY set
* Connected to github.com (13.250.177.223) port 443 (#0)
* found 151 certificates in /etc/ssl/certs/ca-certificates.crt
* found 604 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* Operation timed out after 300044 milliseconds with 0 out of 0 bytes received
* Curl_http_done: called premature == 1
* stopped the pause stream!
* Closing connection 0
fatal: unable to access 'https://github.com/aijm/BSplineSurface.git/': Operation timed out after 300044 milliseconds with 0 out of 0 bytes received
The command '/bin/sh -c GIT_CURL_VERBOSE=1 git clone https://github.com/aijm/BSplineSurface.git' returned a non-zero code: 128

在本机上,输出的结果是:

# 只把关键部分放上来
aijiaming@ubuntu:~$ GIT_CURL_VERBOSE=1 git clone https://github.com/aijm/BSplineSurface.git
Cloning into 'BSplineSurface'...
* Couldn't find host github.com in the .netrc file; using defaults
*   Trying 13.250.177.223...
* Connected to github.com (13.250.177.223) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 594 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: github.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: businessCategory=Private Organization,jurisdictionOfIncorporationCountryName=US,jurisdictionOfIncorporationStateOrProvinceName=Delaware,serialNumber=5157550,C=US,ST=California,L=San Francisco,O=GitHub\, Inc.,CN=github.com
*        start date: Tue, 08 May 2018 00:00:00 GMT
*        expire date: Wed, 03 Jun 2020 12:00:00 GMT
*        issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2 Extended Validation Server CA
*        compression: NULL
* ALPN, server accepted to use http/1.1
> GET /aijm/BSplineSurface.git/info/refs?service=git-upload-pack HTTP/1.1

看着好像是SSL的问题,这部分我没太接触过,不知道为啥前一个到ALPN, offering http/1.1 就断了。

3. 我尝试搜了很多,但大部分资料都是关于ssh配置访问private仓库的,没太看到和我这个类似的问题。

求大佬帮忙看看,我应该如何解决?
谢谢了

阅读 4.3k
1 个回答

dockerfile 里加上

ADD ~/.ssh ~/.ssh
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题