【问题标题】:How to run git clone from docker file requiring SSL certificate如何从需要 SSL 证书的 docker 文件运行 git clone
【发布时间】:2019-02-03 15:27:48
【问题描述】:

我的 Dockerfile 中有以下代码:

FROM alpine/git as clone 
WORKDIR /app
RUN git clone https://github.com/spring-projects/spring-petclinic.git

但是,我收到了这个错误:

fatal: unable to access 'https://github.com/spring-projects/spring-petclinic.git/': SSL certificate problem: self signed certificate in certificate chain

我实际上有一个本地 git,但我无法禁用 SSL 证书。

【问题讨论】:

标签: git docker ssl alpine


【解决方案1】:

尝试添加到您的 Dockerfile,之前 git clone:

RUN apk add --update \
       ca-certificates \
    && update-ca-certificates

从那里,正如评论的那样,您可以使用 HTTPS URL 克隆存储库,例如:

https://username:password@some.company.com/project_name.git 

【讨论】:

  • 谢谢。 alpine Linux 的命令是什么? apt-get 不适用于 alpine。
  • @aQ123 试试apk add --no-cache。参见示例:github.com/gliderlabs/docker-alpine/blob/master/docs/…
  • 我的文件现在看起来像这样,但我收到此错误:主机密钥验证失败。致命:无法从远程存储库中读取。 FROM alpine/git RUN apk add --update \ ca-certificates \ && update-ca-certificates RUN mkdir -p /root/.ssh ADD id_rsa /root/.ssh/id_rsa RUN chmod 700 /root/.ssh/id_rsa WORKDIR /app RUN git clone git@github.com:spring-projects/spring-petclinic.git
  • 尝试使用 https URL 克隆存储库
  • 我尝试使用 https 甚至添加了 GIT_SSL_NO_VERIFY=true 但我收到此错误:致命:无法读取“github.com/spring-projects/spring-petclinic.git”的密码:没有这样的设备或地址
最近更新 更多