I am building a docker image on mac OS (Monterrey) with below dockerfile
FROM golang:latest
WORKDIR /src
COPY go.* ./
RUN go mod download
COPY . /src
RUN go build -o /main
ENTRYPOINT ["/main"]
It works fine til the 3rd line and on the 4th it complains of
=> ERROR [4/6] RUN go mod download 0.2s
------
> [4/6] RUN go mod download:
#8 0.206 go mod download: no modules specified (see 'go help mod download')
------
executor failed running [/bin/sh -c go mod download]: exit code: 1
Any clues what I am doing wrong while the dependencies are being downloaded?
2
Answers
I was missing couple of files from the Working directory as listed below. These are needed to download the dependencies.
Instead of using download do :
You need to specify which package to download when you use "mod download"