我在 golang 中構建了一個小應用程序,使用 alpine:golang 基本映像,其中包括來自 HTTP.get 的響應。我請求的 api 端點通過 HTTPS ( https://jsonplaceholder.typicode.com/users )運行該代碼在本地運行良好,并且 docker 映像構建良好,但運行時出現以下錯誤:The HTTP request failed with error Get "https://jsonplaceholder.typicode.com/users": x509: certificate signed by unknown authority我不確定這是否是特定的 Docker 問題(我無法從其他 Docker 容器卷曲 HTTPS)、我的網絡限制(我不在 VPN 上但我們確實使用 zScaler),或者我是否需要包括/configure 作為我的 Dockerfile 的一部分。我的 dockerfile 看起來像:FROM alpine:golang#Create and set the working directoryRUN mkdir /app WORKDIR /app # Copy all the go scripts into the image working directoryCOPY /pipelines/core/rtbf-pipeline-1 ./# Make the binaries executableRUN chmod +x /app/rtbf-pipeline-1CMD ["app"]任何幫助將不勝感激
2 回答

慕的地10843
TA貢獻1785條經驗 獲得超8個贊
您需要將一組受信任的根證書復制到您的 Docker 映像。
在您Dockerfile添加類似的內容:
FROM golang:alpine AS build
// build your go app here
FROM scratch
// copy go app from `build`
// ...
//
// add trust certs
//
COPY --from=build etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

慕村225694
TA貢獻1880條經驗 獲得超4個贊
您可能需要添加
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
- 2 回答
- 0 關注
- 110 瀏覽
添加回答
舉報
0/150
提交
取消