Last active
May 11, 2021 15:40
-
-
Save pauldraper/b74a24f869b0acbc3bd488d67f9a53b4 to your computer and use it in GitHub Desktop.
Docker ECR credential helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A docker credential helper that automatically calls AWS CLI for docker push/pull. | |
cat <<EOF | |
grep -q 'dkr.ecr.[^.]\+.amazonaws.com' - || exit | |
aws --output text ecr get-authorization-token --query authorizationData[0].authorizationToken \ | |
| base64 --decode \ | |
| sed -e 's/:/", "Secret":"/' -e 's/^/{"Username":"/' -e 's/$/"}/' | |
EOF | sudo tee /usr/local/bin/docker-credential-ecr-login | |
sudo chmod +x /usr/local/bin/docker-credential-ecr-login | |
cat <<EOF | |
{"credsStore": "ecr-login"} | |
EOF > ~/.docker/config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment