如何 运行 git 从需要 SSL 证书的 docker 文件克隆

How to run git clone from docker file requiring SSL certificate

我的 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 证书。

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

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

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

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