About
AWS ECR认证在自动化场景时,使用token方法较为麻烦且会过期,此工具帮助实现对AWS ECR的自动认证
# token认证方法
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123xxxxx123.dkr.ecr.us-east-1.amazonaws.com
Install
安装软件
# ubuntu
apt install -y amazon-ecr-credential-helper
# centos
yum install -y amazon-ecr-credential-helper
无法通过包管理工具安装时可直接使用二进制文件安装:
release package
wget https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/0.7.1/linux-amd64/docker-credential-ecr-login
mv docker-credential-ecr-login /usr/bin/docker-credential-ecr-login
配置Docker credential config;file: ~/.docker/config.json
{
"credsStore": "ecr-login"
}
和现有已存在的Docker登录验证一起使用时:
{
"credsStore": "ecr-login",
"auths": {
"https://index.docker.io/v1/": {
"auth": [your docker.io-auth-token]
},
"registry.gitlab.com": {
"auth": [your gitlab-auth-token]
},
}
}
AWS credentials;需要先安装awscli(详见官方文档)
# 运行配置命令、根据提示配置具有对ECR操作权限的密钥
aws configure
以上配置成功
后即可自动认证进行镜像push/pull等操作
项目地址:GIthub