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?
I was missing couple of files from the Working directory as listed below. These are needed to download the dependencies.
Dockerfile //this was already in the folder. go.sum go.mod main.go
Answered By – cloud jockey
Answer Checked By – David Marino (GoLangFix Volunteer)