Skip to content

Instantly share code, notes, and snippets.

@pauldraper
Last active May 11, 2021 15:40
Show Gist options
  • Save pauldraper/b74a24f869b0acbc3bd488d67f9a53b4 to your computer and use it in GitHub Desktop.
Save pauldraper/b74a24f869b0acbc3bd488d67f9a53b4 to your computer and use it in GitHub Desktop.
Docker ECR credential helper
# 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