You need copy the go.mod file and go.sum files into the container and also set the ENV variable
on like this:
A complete example Dockerfile:
FROM golang:1.12 ENV GO111MODULE=on ENV PORT=8090 WORKDIR /app COPY go.mod . COPY go.sum . RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build EXPOSE 8090 ENTRYPOINT ["/app/your-app-name"]
If still it does not work, try changing the Golang version to a specific latest version like in the example above. I had the problem before with Golang version. But the error you are getting it's because of the go.mod file that does not exist in the container.