Create a repository on the AWS elastic container registry

In order to push a container image to Amazon ECR, you need to create a repository beforehand. Unlike Docker hub or private registry, Amazon ECR doesn't create a repository automatically when it is the first time to push the image. Therefore, if you want to push three container images, you have to create three repositories in advance:

It is simple to type the aws ecr create-repository command to specify the repository name:

$ aws ecr create-repository --repository-name my-nginx
{
"repository": {
"registryId": "************",
"repositoryName": "my-nginx",
"repositoryArn": "arn:aws:ecr:us-east-1:************:repository/my-nginx",
"createdAt": 1516608220.0,
"repositoryUri": "************.dkr.ecr.us-east-1.amazonaws.com/my-nginx"
}
}

That's it! You need to remember the repositoryUri (in the previous case, ************.dkr.ecr.us-east-1.amazonaws.com/my-nginx) that will be used as the private image URL.

The previous URL is masked as an ID as ************. It is tied with your AWS account ID.

On the other hand, if you see something like the following error message, your IAM user doesn't have the permission of the CreateRepository operation. In this case, you need to attach an IAM policy from AmazonEC2ContainerRegistryFullAccess:

$ aws ecr create-repository --repository-name chapter5
An error occurred (AccessDeniedException) when calling the CreateRepository operation: User: arn:aws:iam::************:user/ecr-user is not authorized to perform: ecr:CreateRepository on resource: *
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.160.43