awslabs / amazon-ecr-credential-helper

Automatically gets credentials for Amazon ECR on docker push/docker pull
Apache License 2.0
2.45k stars 335 forks source link

fatal: detected dubious ownership in repository at '/go/src/github.com/awslabs/amazon-ecr-credential-helper' #800

Closed ktasper closed 2 months ago

ktasper commented 2 months ago

When running the following locally:

sudo -E make docker

I get the following error:

docker run --rm \
        --user 0:0 \
        --env TARGET_GOOS= \
        --env TARGET_GOARCH= \
        --volume /tmp/amazon-ecr-credential-helper:/go/src/github.com/awslabs/amazon-ecr-credential-helper \
        sha256:23b97de4f34d4c956e315659157439acfae03f15977d45c57c0e797729064846 \
        make build
git rev-parse --short=7 HEAD > GITCOMMIT_SHA
fatal: detected dubious ownership in repository at '/go/src/github.com/awslabs/amazon-ecr-credential-helper'
To add an exception for this directory, call:

        git config --global --add safe.directory /go/src/github.com/awslabs/amazon-ecr-credential-helper
make: *** [Makefile:95: GITCOMMIT_SHA] Error 128

However running this seems to "fix" this problem.

docker run --rm \
        --user 0:0 \
        --env TARGET_GOOS= \
        --env TARGET_GOARCH= \
        --volume /tmp/amazon-ecr-credential-helper:/go/src/github.com/awslabs/amazon-ecr-credential-helper \
        sha256:23b97de4f34d4c956e315659157439acfae03f15977d45c57c0e797729064846 \
        git config --global --add safe.directory /go/src/github.com/awslabs/amazon-ecr-credential-helper && make build

I have also verified this behaviour on a CICD system.

However I do not see any docs / issues demonstrating this behaviour and it seems incorrect.

ktasper commented 2 months ago

Fix can be found here: https://github.com/awslabs/amazon-ecr-credential-helper/pull/802

austinvazquez commented 2 months ago

Thanks for opening and looking into this. Closing as resolved.