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

aQ1*_*123 7 git ssl docker alpine-linux

我的 Dockerfile 中有以下代码:

FROM alpine/git as clone 
WORKDIR /app
RUN git clone https://github.com/spring-projects/spring-petclinic.git
Run Code Online (Sandbox Code Playgroud)

但是,我收到此错误:

fatal: unable to access 'https://github.com/spring-projects/spring-petclinic.git/': SSL certificate problem: self signed certificate in certificate chain
Run Code Online (Sandbox Code Playgroud)

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

Von*_*onC 9

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

RUN apk add --update \
       ca-certificates \
    && update-ca-certificates
Run Code Online (Sandbox Code Playgroud)

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

https://username:password@some.company.com/project_name.git 
Run Code Online (Sandbox Code Playgroud)