英文:
Lame referral error on go mod download during docker build in RancherDesktop cluster
问题
我在执行Docker构建过程中遇到了一个错误,错误发生在下载Golang依赖项的"RUN go mod download"行。通常会出现许多类似以下的引用错误:
错误信息:
...
=> CACHED [builder 4/7] COPY go.sum go.mod Makefile /app/ 0.0s
=> ERROR [builder 5/7] RUN go mod download 18.5s
------
> [builder 5/7] RUN go mod download:
#12 17.98 go mod download: github.com/aws/aws-sdk-go@v1.44.13: Get "https://storage.googleapis.com/proxy-golang-org-prod/6d16f241873ba42e-github.com:aws:aws-sdk-go-v1.44.13.zip?Expires=x&GoogleAccessId=gcs-urlsigner-prod%40golang-modproxy.iam.gserviceaccount.com&Signature=x": dial tcp: lookup storage.googleapis.com on 192.168.x.x:53: lame referral
...
------
executor failed running [/bin/sh -c go mod download]: exit code: 1
有时候Docker构建会成功,但几乎总是在进行go mod download时的30秒后失败。
我是在企业VPN内部。我可以直接从我的Mac上运行"go mod download"命令轻松地拉取这些依赖项,但是在Docker构建过程中经常遇到此错误。我的队友们在不同地区尝试构建时也遇到类似的问题。如果我们需要配置Docker代理或添加known_hosts,希望能提供具体的示例。
以下是Dockerfile的内容:
FROM golang:1.16.4-buster AS builder
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=1 GOPRIVATE="github.com/x"
ARG GITHUB_ACCESS_TOKEN
RUN mkdir -p -m 0600 /root/.ssh && \
ssh-keyscan github.com >> ~/.ssh/known_hosts && \
git config --global url."https://${GITHUB_ACCESS_TOKEN}:@github.com/".insteadOf "https://github.com/"
# separate for better caching purpose
WORKDIR /app
COPY go.sum go.mod Makefile /app/
RUN go mod download
COPY . .
RUN make install && make build
...
英文:
I encounter an error during my docker build on the "RUN go mod download" line that is downloading Golang dependencies. It usually fails with numerous lame referral errors like the following:
Error:
...
=> CACHED [builder 4/7] COPY go.sum go.mod Makefile /app/ 0.0s
=> ERROR [builder 5/7] RUN go mod download 18.5s
------
> [builder 5/7] RUN go mod download:
#12 17.98 go mod download: github.com/aws/aws-sdk-go@v1.44.13: Get "https://storage.googleapis.com/proxy-golang-org-prod/6d16f241873ba42e-github.com:aws:aws-sdk-go-v1.44.13.zip?Expires=x&GoogleAccessId=gcs-urlsigner-prod%40golang-modproxy.iam.gserviceaccount.com&Signature=x": dial tcp: lookup storage.googleapis.com on 192.168.x.x:53: lame referral
...
------
executor failed running [/bin/sh -c go mod download]: exit code: 1
Every once in a while the docker build will work, but it almost always fails after 30s during this go mod download.
I'm within a corporate VPN. I can pull these dependencies directly from my Mac easily by directly running "go mod download", but docker build encounters this error very often. My teammates experience similar issues when they try to build as well from different regions. If we need to configure a docker proxy or add known_hosts, specific examples would be appreciated.
Dockerfile:
FROM golang:1.16.4-buster AS builder
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=1 GOPRIVATE="github.com/x"
ARG GITHUB_ACCESS_TOKEN
RUN mkdir -p -m 0600 /root/.ssh && \
ssh-keyscan github.com >> ~/.ssh/known_hosts && \
git config --global url."https://${GITHUB_ACCESS_TOKEN}:@github.com/".insteadOf "https://github.com/"
# separate for better caching purpose
WORKDIR /app
COPY go.sum go.mod Makefile /app/
RUN go mod download
COPY . .
RUN make install && make build
...
答案1
得分: 1
我还不确定这是否是一个持久的解决方法,但是我通过以下比较冗长的过程解决了今天的问题:
minikube stop
(minikube 连接到我的本地 RancherDesktop 集群)- 重新启动 RancherDesktop(同时更新它)
minikube start
- 这告诉我 docker 的磁盘空间不足minikube delete
(可能有点过头了,minikube ssh -- docker system prune
可能也可以解决)minikube start
eval $(minikube -p minikube docker-env)
- 构建和启动我的服务(使用 Skaffold 利用 Docker 构建和通过 minikube 使用 Helm 部署)
不要提供无用的参考!
英文:
I'm not sure yet if this is a consistent fix, but I was able to resolve this for today via the following unfortunately long process:
minikube stop
(minikube connects to my local RancherDesktop cluster)- re-start RancherDesktop (also updated it)
minikube start
- this informed me that docker was out of disk spaceminikube delete
(maybe overkill,minikube ssh -- docker system prune
might have worked)minikube start
eval $(minikube -p minikube docker-env)
- build and start my service/s (using Skaffold which utilizes Docker to build and Helm via minikube to deploy)
No lame referrals!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论