使用临时Docker容器时,显示以下错误消息“”无法解组DNS消息”

I am trying to run a scratch docker container on my local from my go code. The Dockerfile is as follows:

FROM golang:1.11.4 as builder


WORKDIR /app

ADD . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64  GOARM=7 make

FROM scratch
COPY --from=builder /app/myprogram .

In my code I try to connect to mongodb using the following url mongodb+srv://myusername:mypassword@my-staging-vki7g.gcp.mongodb.net

I can connect to this mongodb perfectly fine on my local mongoshell. However, when I run my scracth container, I get the following error

error parsing uri (mongodb+srv://myusername:mypassword@my-staging-vki7g.gcp.mongodb.net): lookup provendb-staging-vki7g.gcp.mongodb.net on 192.168.65.1:53: cannot unmarshal DNS message

Are there any dependencies that need to be added?

I think you miss some build flags. Also not sure why you would want to compile as arm for a docker container.

I wrote a blog post on building a Docker image like you do here. That might help you resolve your issue.

https://marcofranssen.nl/docker-tips-and-tricks-for-your-go-projects/