
上QQ阅读APP看书,第一时间看更新
Creating ECR repositories using the AWS CLI
Creating an ECR repository can be performed using the AWS CLI by running the aws ecr create-repository command, however given you have already created your repository via the AWS console, let's see how you can check whether an ECR repository already exists and how to delete a repository using the AWS CLI.
To view a list of ECR repositories in your AWS account and local region, you can use the aws ecr list-repositories command, while to delete an ECR repository, you can use the aws ecr delete-repository command, as demonstrated here:
> aws ecr list-repositories
{
"repositories": [
{
"repositoryArn": "arn:aws:ecr:us-east-1:385605022855:repository/docker-in-aws/todobackend",
"registryId": "385605022855",
"repositoryName": "docker-in-aws/todobackend",
"repositoryUri": "385605022855.dkr.ecr.us-east-1.amazonaws.com/docker-in-aws/todobackend",
"createdAt": 1517692382.0
}
]
}
> aws ecr delete-repository --repository-name docker-in-aws/todobackend
{
"repository": {
"repositoryArn": "arn:aws:ecr:us-east-1:385605022855:repository/docker-in-aws/todobackend",
"registryId": "385605022855",
"repositoryName": "docker-in-aws/todobackend",
"repositoryUri": "385605022855.dkr.ecr.us-east-1.amazonaws.com/docker-in-aws/todobackend",
"createdAt": 1517692382.0
}
}
Describing and deleting an ECR Repository using the AWS CLI
Now that you have deleted the repository you created earlier using the AWS console, you can re-create it, as demonstrated here:
> aws ecr create-repository --repository-name docker-in-aws/todobackend
{
"repository": {
"repositoryArn": "arn:aws:ecr:us-east-1:385605022855:repository/docker-in-aws/todobackend",
"registryId": "385605022855",
"repositoryName": "docker-in-aws/todobackend",
"repositoryUri": "385605022855.dkr.ecr.us-east-1.amazonaws.com/docker-in-aws/todobackend",
"createdAt": 1517693074.0
}
}
Creating an ECR Repository using the AWS CLI