Skip to content

Instantly share code, notes, and snippets.

@neilkuan
Created April 18, 2020 08:32
Show Gist options
  • Save neilkuan/bcc012038344de4dc820c3113c4a6b91 to your computer and use it in GitHub Desktop.
Save neilkuan/bcc012038344de4dc820c3113c4a6b91 to your computer and use it in GitHub Desktop.
# need awscli >= 1.16.x , docker
# aws ecr get-login --registry-ids < ecr-account-id > --region < region-you-want > --no-include-email
#way 1.
# Get docker registry token from A account ECR
[ec2-user@192-168-0-99 ~ ] aws ecr get-login --registry-ids 1333333333 --region ap-northeast-1 --no-include-email
#--output
docker login -u AWS -p eyJwYXlsb2FkIjoi....NUZCeTkydVU2b2R9 https://1333333333.dkr.ecr.us-east-1.amazonaws.com
# Copy output for Login A account ECR
[ec2-user@192-168-0-99 ~ ] docker login -u AWS -p eyJwYXlsb2FkIjoi....NUZCeTkydVU2b2R9 https://1333333333.dkr.ecr.us-east-1.amazonaws.com
#--output
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
#way 2.
# Get docker registry token from A account ECR and auto login A account ECR
[ec2-user@192-168-0-99 ~ ] $(aws ecr get-login --registry-ids 1333333333 --region ap-northeast-1 --no-include-email)
#--output
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment