Git无法在HTTP代理后面的dockerfile中工作

时间:2019-09-17 21:36:45

标签: git docker http ssl-certificate

几天来我一直在努力解决这个问题,但一直没有成功。

这里是设置:一切都在公司防火墙后面运行。我有一个带有ubuntu映像的dockerfile。防火墙后一切正常,我已经设置了证书和代理设置。唯一不起作用的是git。我无法克隆任何东西。

我已经这样设置了证书和代理:

RUN git config --global http.proxy http://165.225.80.41:80 RUN git config --global http.sslCAPath /usr/local/share/ca-certificates/abcd/abcd.crt
RUN git config --global http.sslCAInfo /usr/local/share/ca-certificates/abcd/abcd.crt
RUN git clone https://github.com/asd/asd.git

这是我运行它时得到的:

Step 39/156 : RUN git clone https://github.com/asd/asd.git
 ---> Running in e20ef1c7ac5d
Cloning into 'asd'...
error: RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated

2 个答案:

答案 0 :(得分:0)

  

错误:RPC失败; curl 56 GnuTLS接收错误(-110):TLS   连接不正确

该错误不是来自代理或由于代理引起的,但错误是由于git导致的,要么安装不正确,要么在安装过程中错过了某些东西。

可能的解决方案

如果未安装OpenSSL,则安装

RUN sudo apt install openssl

尝试ssh

RUN git clone git@github.com/asd/asd.git

您可以检查其他可能的原因here

或者您可以尝试

RUN git config --global http.proxy http://165.225.80.41:80 && \
git config --global http.sslCAPath /usr/local/share/ca-certificates/abcd/abcd.crt && \
git config --global http.sslCAInfo /usr/local/share/ca-certificates/abcd/abcd.crt && \
git clone https://github.com/asd/asd.git

答案 1 :(得分:0)

问题不是git的代理设置。由于GnuTLS,Git在ubuntu LTS中无法正常工作。仅在某些情况下在代理后使用Ubuntu时失败。唯一的解决方案是使用OpenSSL而非GnulTLS从源代码重建git。

这似乎是解决问题的非常复杂的方法,但是在此之前,我尝试了许多不同的解决方案,但均未奏效。这是我尝试过的东西的摘要:

  • Linux环境变量
  • 证书和git和Linux的代理设置
  • Docker设置,环境和状态保护
  • 重新安装Git和GnuTLS
  • 将ubuntu更新为ubuntu 18
  • 使用Wget克隆,在容器外部卷曲克隆并复制