1 min read

AWS ECR private container 私有鏡像下載

1.需要安裝 AWS CLI 官網

2.需給予AWS IAM權限 如果只想要下載鏡像的話可以使用以下規則組

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Effect": "Allow",
			"Action": [
				"ecr:GetDownloadUrlForLayer",
				"ecr:BatchGetImage",
				"ecr:BatchCheckLayerAvailability",
				"ecr:GetAuthorizationToken",
				"ecr:DescribeRepositories"
			],
			"Resource": "*"
		}
	]
}


aws configure

aws configure

aws cli

{region} 要替換成相對應的區域 ex: ap-northeast-3
{aws-id} AWS 帳號ID

#!/bin/bash
set -e
set -o pipefail

AWS_ID=""
AWS_REGION="ap-northeast-3"

aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ID.dkr.ecr.$AWS_REGION.amazonaws.com

aws ecr

aws ecr describe-repositories|grep repositoryName 查詢當前所有容器