I'm trying to build my go project in the docker container.
Here is the dockerfile:
FROM golang:1.12.9 as builder
ENV GO111MODULE=on
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o encashment
FROM scratch
COPY --from=builder /app/encashment /encashment/
EXPOSE 8080
ENTRYPOINT ["/app/encashment"]
I have only one dependency in go.mod:
require github.com/gorilla/mux v1.7.3
If I delete gorilla/mux
locally and call go mod download
, everyhing works fine. But when I call docker build .
it returns
go: finding github.com/gorilla/mux v1.7.3
go: github.com/gorilla/[email protected]: unknown revision v1.7.3
go: error loading module requirements
How to make this work?
UPD: Here is the piece of tcpdump output:
19:00:00.220102 IP 172.17.0.2.43627 > dns.google.domain: 15472+ A? github.com. (28)
19:00:00.220115 IP 172.17.0.2.43627 > dns.google.domain: 64629+ AAAA? github.com. (28)
19:00:02.969391 IP 172.17.0.1.38261 > 239.255.255.250.1900: UDP, length 172
19:00:03.971322 IP 172.17.0.1.38261 > 239.255.255.250.1900: UDP, length 172
19:00:04.971794 IP 172.17.0.1.38261 > 239.255.255.250.1900: UDP, length 172
19:00:05.221952 IP 172.17.0.2.40395 > dns.google.domain: 15472+ A? github.com. (28)
19:00:05.221992 IP 172.17.0.2.40395 > dns.google.domain: 64629+ AAAA? github.com. (28)
19:00:05.970002 IP 172.17.0.1.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _googlecast._tcp.local. (40)
19:00:05.970263 IP 172.17.0.1.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _googlecast._tcp.local. (40)
19:00:05.972573 IP 172.17.0.1.38261 > 239.255.255.250.1900: UDP, length 172
19:00:06.971288 IP 172.17.0.1.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _googlecast._tcp.local. (40)
19:00:06.971446 IP 172.17.0.1.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _googlecast._tcp.local. (40)
19:00:08.972581 IP 172.17.0.1.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _googlecast._tcp.local. (40)
19:00:08.972736 IP 172.17.0.1.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _googlecast._tcp.local. (40)
19:00:10.224125 IP 172.17.0.2.43627 > dns.google.domain: 15472+ A? github.com. (28)
19:00:10.224171 IP 172.17.0.2.43627 > dns.google.domain: 64629+ AAAA? github.com. (28)
In addition to Docker, other container support software has been developed in Go, including the Kubernetes container management software and Hashicorp's Nomad cluster management software.
The storage location of Docker images and containers Ubuntu: /var/lib/docker/ Fedora: /var/lib/docker/ Debian: /var/lib/docker/ Windows: C:\ProgramData\DockerDesktop.
Alpine Linux is a Linux distribution built around musl libc and BusyBox. The image is only 5 MB in size and has access to a package repository that is much more complete than other BusyBox based images. This makes Alpine Linux a great image base for utilities and even production applications.
Well, thanks to @prometherion The problem was in the absence of internet access from within of docker container. This SO answer worked for me. Guess that I should create an issue in golang repo and ask to rework this error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With