我有下面的dockerfile,当我尝试运行docker build时,我得到一个错误。
dockerfile
# base go image
FROM golang:latest as builder
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN CGO_ENABLED=0 go build -o brokerApp ./cmd/api
RUN chmod +x /app/brokerApp
# build a tiny docker image
FROM alpine:latest
RUN mkdir /app
COPY --from=builder /app/brokerApp /app
CMD [ "/app/brokerApp" ]
误差
$ docker build -t test -f broker-service.dockerfile .
Sending build context to Docker daemon 7.79MB
Step 1/10 : FROM golang:latest as builder
---> c48137eaf961
Step 2/10 : RUN mkdir /app
---> Running in 0caaa78d39ad
Removing intermediate container 0caaa78d39ad
---> 260a46b545a8
Step 3/10 : COPY . /app
---> 17c49c16a2ea
Step 4/10 : WORKDIR /app
---> Running in 056c8e90776a
Removing intermediate container 056c8e90776a
---> 55ef7bc5f453
Step 5/10 : RUN CGO_ENABLED=0 go build -o brokerApp ./cmd/api
---> Running in e1d6ae8ddbb6
go: downloading github.com/go-chi/chi/v5 v5.0.8
go: downloading github.com/go-chi/cors v1.2.1
cmd/api/routes.go:6:2: github.com/go-chi/chi/v5@v5.0.8: Get "https://proxy.golang.org/github.com/go-chi/chi/v5/@v/v5.0.8.zip": tls: failed to verify certificate: x509: certificate signed by unknown authority
cmd/api/routes.go:7:2: github.com/go-chi/chi/v5@v5.0.8: Get "https://proxy.golang.org/github.com/go-chi/chi/v5/@v/v5.0.8.zip": tls: failed to verify certificate: x509: certificate signed by unknown authority
cmd/api/routes.go:8:2: github.com/go-chi/cors@v1.2.1: Get "https://proxy.golang.org/github.com/go-chi/cors/@v/v1.2.1.zip": tls: failed to verify certificate: x509: certificate signed by unknown authority
The command '/bin/sh -c CGO_ENABLED=0 go build -o brokerApp ./cmd/api' returned a non-zero code: 1
有趣的是,当我直接点击浏览器https://proxy.golang.org/github.com/go-chi/chi/v5/@v/v5.0.8.zip
上的网址时,它下载的zip文件就很好。
我被困在这个问题上,因为几天,并尝试了几乎所有类似的职位。
go版本go1.19.5 windows/amd 64
操作系统- windows
1条答案
按热度按时间bqf10yzr1#
我通过将机器的证书添加到docker容器来解决这个错误: