Push a locally created Docker image to ECR using the AWS CLI
· AWS CLI version 2 ・ Docker image created
Here's a summary of Pushing images to Amazon Elastic Container Registry It is what I did. There were times when I couldn't pass the command, so I've written about it.
--Access key ID --Secret access key --AWS Region --Output format
It is recommended to specify --profile
as shown below when configuring.
Here, I named it prf-name
.
aws configure --profile prf-name
If you set this, when you use the aws command, if you specify the setting information created with --profile
like the following, you can easily tell the command where you want to access. is.
aws s3 ls --profile prf-name
If you do not specify --profile
, you will not be able to specify the authentication information as shown below, so be careful with aws configure
first.
Unable to locate credentials. You can configure credentials by running "aws configure"
If you want to check the list of created profiles, execute the following. This is convenient when you forget the name you set.
aws configure list-profiles
aws ecr create-repository --repository-name your-repository-name --region region --profile prf-name
your-repository-name
: Favorite repository name
region
: Region (eg ap-northeast-1)
There is no description on the official website, but if you do not describe --profile
, the authentication error message mentioned earlier will be displayed.
aws ecr create-repository --repository-name hello-repository --region region
hello-repository
: repository name
region
: Region (eg ap-northeast-1)
output:
{
"repository": {
"registryId": "aws_account_id",
"repositoryName": "hello-repository",
"repositoryArn": "arn:aws:ecr:region:aws_account_id:repository/hello-repository",
"createdAt": 1505337806.0,
"repositoryUri": "aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository"
}
}
docker tag hello-world aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository
aws ecr get-login-password --profile prf-name | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
output:
Login Succeeded
docker push aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository
list-images
aws ecr list-images --repository-name hello-repository --region region --profile prf-name
Recommended Posts