I have this simple Dockerfile:
FROM golang:1.16.6-buster
RUN wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2
RUN golangci-lint --version
When I build it, no matter how I change the second line above, I am always getting:
> [3/3] RUN golangci-lint --version:
#6 0.331 /bin/sh: 1: golangci-lint: not found
What exactly I am doing wrong here?
If I try:
FROM golang:1.16.6-buster
RUN curl -s https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
| sh -s v1.45.2
RUN bin/golangci-lint version
I get this detailed output:
docker build -t gotest .
[+] Building 0.9s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/golang:1.16.6-buster 0.5s
=> [1/3] FROM docker.io/library/golang:1.16.6-buster@sha256:f3923dc5a92a237db0f07a924a238a8a4a711e3b77a7b5bdb1b526e107dcb9d4 0.0s
=> CACHED [2/3] RUN curl -s https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2 0.0s
=> ERROR [3/3] RUN bin/golangci-lint version 0.2s
------
> [3/3] RUN bin/golangci-lint version:
#6 0.214 /bin/sh: 1: bin/golangci-lint: not found
------
executor failed running [/bin/sh -c bin/golangci-lint version]: exit code: 127
Trying:
FROM golang:1.16.6-buster
RUN curl -s https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
| sh -s v1.45.2
RUN /go/bin/golangci-lint version
Output:
docker build .
[+] Building 1.7s (7/7) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 212B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 32B 0.0s
=> [internal] load metadata for docker.io/library/golang:1.16.6-buster 1.3s
=> [auth] library/golang:pull token for registry-1.docker.io 0.0s
=> [1/3] FROM docker.io/library/golang:1.16.6-buster@sha256:f3923dc5a92a237db0f07a924a238a8a4a711e3b77a7b5bdb1b526e107dcb9d4 0.0s
=> CACHED [2/3] RUN curl -s https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2 0.0s
=> ERROR [3/3] RUN /go/bin/golangci-lint version 0.3s
------
> [3/3] RUN /go/bin/golangci-lint version:
#7 0.276 /bin/sh: 1: /go/bin/golangci-lint: not found
------
executor failed running [/bin/sh -c /go/bin/golangci-lint version]: exit code: 127
2
Answers
This is how it worked finally. No binary was getting downloaded due to versions mismatch. I upgraded Go to
1.16 0
and the linter to1.45.2
. Also instead ofwget
I went forgo install
which works with this Go version. This got a binary downloaded in the default folder/bin
and the CI job was fixed.golangci-lint
is inbin
directory :build output :