Unable to install docker-credential-ecr-login using `go install`
kameshsampath opened this issue · comments
/question
As developer trying to use docker-credential-ecr-login
, I tried installing using go install
go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@v0.6.0
It results in the following error,
go: github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@v0.6.0: module github.com/awslabs/amazon-ecr-credential-helper@v0.6.0 found, but does not contain package github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login
If I do go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@latest
it works. but I need to pin to a version of the binary.
Any clues?
It is my understanding that you have to give the directory that contains go.mod
:
So, for instance:
go install github.com/santhosh-tekuri/jsonschema/cmd/jv@v0.4.0
works.
However,
go install "github.com/awslabs/amazon-ecr-credential-helper/ecr-login@v0.7.1
does not work, either:
go: github.com/awslabs/amazon-ecr-credential-helper/ecr-login@v0.7.1: module github.com/awslabs/amazon-ecr-credential-helper@v0.7.1 found, but does not contain package github.com/awslabs/amazon-ecr-credential-helper/ecr-login
This is with golang 1.20.6.
My suspicion is that go.mod
and main.go
need to be located in the same directory, but I certainly don't fully understand how go install
resolves its arguments; the help output is confusing.
In the meantime, I do this as part of my Docker build:
# renovate: datasource=github-tags depName=awslabs/amazon-ecr-credential-helper versioning=semver
ENV AWS_ECR_CRED_HELPER_VERSION="v0.7.1"
RUN apk add --no-cache wget \
&& wget -nv -O /go/bin/docker-credential-ecr-login \
https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${AWS_ECR_CRED_HELPER_VERSION#v}/linux-amd64/docker-credential-ecr-login \
&& chmod +x /go/bin/docker-credential-ecr-login