Exemples d’utilisation de l’AWS CLI avec Amazon ECR Public
Les exemples de code suivants montrent comment réaliser des actions et mettre en œuvre des scénarios courants en utilisant l’AWS Command Line Interface avec Amazon ECR Public.
Les actions sont des extraits de code de programmes plus larges et doivent être exécutées dans leur contexte. Alors que les actions vous indiquent comment appeler des fonctions de service individuelles, vous pouvez les voir en contexte dans leurs scénarios associés.
Chaque exemple inclut un lien vers le code source complet, où vous trouverez des instructions sur la configuration et l’exécution du code en contexte.
Rubriques
Actions
L’exemple de code suivant montre comment utiliser batch-delete-image.
- AWS CLI
-
Exemple 1 : pour supprimer une image à l’aide des ID de résumé d’image, l’image et toutes ses balises sont supprimées d’un référentiel dans un registre public
L’exemple
batch-delete-imagesuivant supprime une image en spécifiant le résumé de l’image.aws ecr-public batch-delete-image \ --repository-nameproject-a/nginx-web-app\ --image-idsimageDigest=sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2Sortie :
{ "imageIds": [ { "imageDigest": "sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2", "imageTag": "latest" } ], "failures": [] }Pour plus d’informations, consultez Deleting an image in a public repository dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour supprimer une image en spécifiant la balise associée à l’image à supprimer du référentiel.
L’exemple
batch-delete-imagesuivant supprime une image en spécifiant la balise associée au référentiel d’images nomméproject-a/nginx-web-appdans un registre public. Si vous n’avez qu’une seule balise et que vous exécutez cette commande, l’image sera supprimée. Sinon, si vous avez plusieurs balises pour la même image, spécifiez-en une seule pour que seule cette balise soit supprimée du référentiel, pas l’image.aws ecr-public batch-delete-image \ --repository-nameproject-a/nginx-web-app\ --image-idsimageTag=_tempSortie :
{ "imageIds": [ { "imageDigest": "sha256:f7a86a0760e2f8d7eff07e515fc87bf4bac45c35376c06f9a280f15ecad6d7e0", "imageTag": "_temp" } ], "failures": [] }Pour plus d’informations, consultez Deleting an image in a public repository dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 3 : pour supprimer plusieurs images, vous pouvez spécifier plusieurs balises ou résumés d’image dans la demande pour un référentiel dans un registre public.
L’exemple
batch-delete-imagesuivant supprime plusieurs images d’un référentiel nommé project-a/nginx-web-app en spécifiant plusieurs balises ou résumés d’images dans la demande.aws ecr-public batch-delete-image \ --repository-nameproject-a/nginx-web-app\ --image-idsimageTag=temp2.0imageDigest=sha256:47ba980bc055353d9c0af89b1894f68faa43ca93856917b8406316be86f01278Sortie :
{ "imageIds": [ { "imageDigest": "sha256:47ba980bc055353d9c0af89b1894f68faa43ca93856917b8406316be86f01278" }, { "imageDigest": "sha256:f7a86a0760e2f8d7eff07e515fc87bf4bac45c35376c06f9a280f15ecad6d7e0", "imageTag": "temp2.0" } ], "failures": [] }Pour plus d’informations, consultez Deleting an image in a public repository dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 4 : pour supprimer une image entre des comptes AWS à l’aide des identifiants registry-id et imagedigest, l’image et toutes ses balises sont supprimées d’un référentiel dans un registre public
L’exemple
batch-delete-imagesuivant supprime une image en spécifiant le résumé de l’image dans le compte croisé AWS :aws ecr-public batch-delete-image \ --registry-id123456789098\ --repository-nameproject-a/nginx-web-app\ --image-idsimageDigest=sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2\ --regionus-east-1Sortie :
{ "imageIds": [ { "imageDigest": "sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2", "imageTag": "temp2.0" } ], "failures": [] }Pour plus d’informations, consultez Deleting an image in a public repository dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez BatchDeleteImage
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser create-repository.
- AWS CLI
-
Exemple 1 : pour créer un référentiel dans un registre public
L’exemple
create-repositorysuivant crée un référentiel nommé project-a/nginx-web-app dans un registre public.aws ecr-public create-repository \ --repository-nameproject-a/nginx-web-appSortie :
{ "repository": { "repositoryArn": "arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app", "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "repositoryUri": "public.ecr.aws/public-registry-custom-alias/project-a/nginx-web-app", "createdAt": "2024-07-01T21:08:55.131000+00:00" }, "catalogData": {} }Pour plus d’informations, consultez Creating a public repository dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour créer, dans un registre public, un référentiel avec une brève description de son contenu, du système et de l’architecture d’exploitation avec lesquels les images du référentiel sont compatibles
L’exemple
create-repositorysuivant crée un référentiel nommé project-a/nginx-web-app dans un registre public avec une brève description du contenu du référentiel, du système et de l’architecture d’exploitation avec lesquels les images du référentiel sont compatibles.aws ecr-public create-repository \ --repository-nameproject-a/nginx-web-app\ --catalog-data 'description=My project-a ECR Public Repository,architectures=ARM,ARM 64,x86,x86-64,operatingSystems=Linux'Sortie :
{ "repository": { "repositoryArn": "arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app", "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "repositoryUri": "public.ecr.aws/public-registry-custom-alias/project-a/nginx-web-app", "createdAt": "2024-07-01T21:23:20.455000+00:00" }, "catalogData": { "description": "My project-a ECR Public Repository", "architectures": [ "ARM", "ARM 64", "x86", "x86-64" ], "operatingSystems": [ "Linux" ] } }Pour plus d’informations, consultez Creating a public repository dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 3 : pour créer un référentiel dans un registre public, avec les informations concernant logoImageBlob, aboutText, usageText et les balises
L’exemple
create-repositorysuivant crée un référentiel nommé project-a/nginx-web-app dans un registre public, avec les informations concernant logoImageBlob, aboutText, usageText et les balises.aws ecr-public create-repository \ --cli-input-jsonfile://myfile.jsonContenu de
myfile.json:{ "repositoryName": "project-a/nginx-web-app", "catalogData": { "description": "My project-a ECR Public Repository", "architectures": [ "ARM", "ARM 64", "x86", "x86-64" ], "operatingSystems": [ "Linux" ], "logoImageBlob": "iVBORw0KGgoA<<truncated-for-better-reading>>ErkJggg==", "aboutText": "## Quick reference\n\nMaintained by: [the Amazon Linux Team](https://github.com/aws/amazon-linux-docker-images)\n\nWhere to get help: [the Docker Community Forums](https://forums.docker.com/), [the Docker Community Slack](https://dockr.ly/slack), or [Stack Overflow](https://stackoverflow.com/search?tab=newest&q=docker)\n\n## Supported tags and respective `dockerfile` links\n\n* [`2.0.20200722.0`, `2`, `latest`](https://github.com/amazonlinux/container-images/blob/03d54f8c4d522bf712cffd6c8f9aafba0a875e78/Dockerfile)\n* [`2.0.20200722.0-with-sources`, `2-with-sources`, `with-sources`](https://github.com/amazonlinux/container-images/blob/1e7349845e029a2e6afe6dc473ef17d052e3546f/Dockerfile)\n* [`2018.03.0.20200602.1`, `2018.03`, `1`](https://github.com/amazonlinux/container-images/blob/f10932e08c75457eeb372bf1cc47ea2a4b8e98c8/Dockerfile)\n* [`2018.03.0.20200602.1-with-sources`, `2018.03-with-sources`, `1-with-sources`](https://github.com/amazonlinux/container-images/blob/8c9ee491689d901aa72719be0ec12087a5fa8faf/Dockerfile)\n\n## What is Amazon Linux?\n\nAmazon Linux is provided by Amazon Web Services (AWS). It is designed to provide a stable, secure, and high-performance execution environment for applications running on Amazon EC2. The full distribution includes packages that enable easy integration with AWS, including launch configuration tools and many popular AWS libraries and tools. AWS provides ongoing security and maintenance updates to all instances running Amazon Linux.\n\nThe Amazon Linux container image contains a minimal set of packages. To install additional packages, [use `yum`](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-software.html).\n\nAWS provides two versions of Amazon Linux: [Amazon Linux 2](https://aws.amazon.com/amazon-linux-2/) and [Amazon Linux AMI](https://aws.amazon.com/amazon-linux-ami/).\n\nFor information on security updates for Amazon Linux, please refer to [Amazon Linux 2 Security Advisories](https://alas.aws.amazon.com/alas2.html) and [Amazon Linux AMI Security Advisories](https://alas.aws.amazon.com/). Note that Docker Hub's vulnerability scanning for Amazon Linux is currently based on RPM versions, which does not reflect the state of backported patches for vulnerabilities.\n\n## Where can I run Amazon Linux container images?\n\nYou can run Amazon Linux container images in any Docker based environment. Examples include, your laptop, in Amazon EC2 instances, and Amazon ECS clusters.\n\n## License\n\nAmazon Linux is available under the [GNU General Public License, version 2.0](https://github.com/aws/amazon-linux-docker-images/blob/master/LICENSE). Individual software packages are available under their own licenses; run `rpm -qi [package name]` or check `/usr/share/doc/[package name]-*` and `/usr/share/licenses/[package name]-*` for details.\n\nAs with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).\n\nSome additional license information which was able to be auto-detected might be found in [the `repo-info` repository's `amazonlinux/` directory](https://github.com/docker-library/repo-info/tree/master/repos/amazonlinux).\n\n## Security\n\nFor information on security updates for Amazon Linux, please refer to [Amazon Linux 2 Security Advisories](https://alas.aws.amazon.com/alas2.html) and [Amazon Linux AMI Security Advisories](https://alas.aws.amazon.com/). Note that Docker Hub's vulnerability scanning for Amazon Linux is currently based on RPM versions, which does not reflect the state of backported patches for vulnerabilities.", "usageText": "## Supported architectures\n\namd64, arm64v8\n\n## Where can I run Amazon Linux container images?\n\nYou can run Amazon Linux container images in any Docker based environment. Examples include, your laptop, in Amazon EC2 instances, and ECS clusters.\n\n## How do I install a software package from Extras repository in Amazon Linux 2?\n\nAvailable packages can be listed with the `amazon-linux-extras` command. Packages can be installed with the `amazon-linux-extras install <package>` command. Example: `amazon-linux-extras install rust1`\n\n## Will updates be available for Amazon Linux containers?\n\nSimilar to the Amazon Linux images for Amazon EC2 and on-premises use, Amazon Linux container images will get ongoing updates from Amazon in the form of security updates, bug fix updates, and other enhancements. Security bulletins for Amazon Linux are available at https://alas.aws.amazon.com/\n\n## Will AWS Support the current version of Amazon Linux going forward?\n\nYes; in order to avoid any disruption to your existing applications and to facilitate migration to Amazon Linux 2, AWS will provide regular security updates for Amazon Linux 2018.03 AMI and container image for 2 years after the final LTS build is announced. You can also use all your existing support channels such as AWS Support and Amazon Linux Discussion Forum to continue to submit support requests." }, "tags": [ { "Key": "Name", "Value": "project-a/nginx-web-app" }, { "Key": "Environment", "Value": "Prod" } ] }Sortie :
{ "repository": { "repositoryArn": "arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app", "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "repositoryUri": "public.ecr.aws/public-registry-custom-alias/project-a/nginx-web-app", "createdAt": "2024-07-01T21:53:05.749000+00:00" }, "catalogData": { "description": "My project-a ECR Public Repository", "architectures": [ "ARM", "ARM 64", "x86", "x86-64" ], "operatingSystems": [ "Linux" ], "logoUrl": "https://d3g9o9u8re44ak.cloudfront.net/logo/23861450-4b9b-403c-9a4c-7aa0ef140bb8/2f9bf5a7-a32f-45b4-b5cd-c5770a35e6d7.png", "aboutText": "## Quick reference\n\nMaintained by: [the Amazon Linux Team](https://github.com/aws/amazon-linux-docker-images)\n\nWhere to get help: [the Docker Community Forums](https://forums.docker.com/), [the Docker Community Slack](https://dockr.ly/slack), or [Stack Overflow](https://stackoverflow.com/search?tab=newest&q=docker)\n\n## Supported tags and respective `dockerfile` links\n\n* [`2.0.20200722.0`, `2`, `latest`](https://github.com/amazonlinux/container-images/blob/03d54f8c4d522bf712cffd6c8f9aafba0a875e78/Dockerfile)\n* [`2.0.20200722.0-with-sources`, `2-with-sources`, `with-sources`](https://github.com/amazonlinux/container-images/blob/1e7349845e029a2e6afe6dc473ef17d052e3546f/Dockerfile)\n* [`2018.03.0.20200602.1`, `2018.03`, `1`](https://github.com/amazonlinux/container-images/blob/f10932e08c75457eeb372bf1cc47ea2a4b8e98c8/Dockerfile)\n* [`2018.03.0.20200602.1-with-sources`, `2018.03-with-sources`, `1-with-sources`](https://github.com/amazonlinux/container-images/blob/8c9ee491689d901aa72719be0ec12087a5fa8faf/Dockerfile)\n\n## What is Amazon Linux?\n\nAmazon Linux is provided by Amazon Web Services (AWS). It is designed to provide a stable, secure, and high-performance execution environment for applications running on Amazon EC2. The full distribution includes packages that enable easy integration with AWS, including launch configuration tools and many popular AWS libraries and tools. AWS provides ongoing security and maintenance updates to all instances running Amazon Linux.\n\nThe Amazon Linux container image contains a minimal set of packages. To install additional packages, [use `yum`](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-software.html).\n\nAWS provides two versions of Amazon Linux: [Amazon Linux 2](https://aws.amazon.com/amazon-linux-2/) and [Amazon Linux AMI](https://aws.amazon.com/amazon-linux-ami/).\n\nFor information on security updates for Amazon Linux, please refer to [Amazon Linux 2 Security Advisories](https://alas.aws.amazon.com/alas2.html) and [Amazon Linux AMI Security Advisories](https://alas.aws.amazon.com/). Note that Docker Hub's vulnerability scanning for Amazon Linux is currently based on RPM versions, which does not reflect the state of backported patches for vulnerabilities.\n\n## Where can I run Amazon Linux container images?\n\nYou can run Amazon Linux container images in any Docker based environment. Examples include, your laptop, in Amazon EC2 instances, and Amazon ECS clusters.\n\n## License\n\nAmazon Linux is available under the [GNU General Public License, version 2.0](https://github.com/aws/amazon-linux-docker-images/blob/master/LICENSE). Individual software packages are available under their own licenses; run `rpm -qi [package name]` or check `/usr/share/doc/[package name]-*` and `/usr/share/licenses/[package name]-*` for details.\n\nAs with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).\n\nSome additional license information which was able to be auto-detected might be found in [the `repo-info` repository's `amazonlinux/` directory](https://github.com/docker-library/repo-info/tree/master/repos/amazonlinux).\n\n## Security\n\nFor information on security updates for Amazon Linux, please refer to [Amazon Linux 2 Security Advisories](https://alas.aws.amazon.com/alas2.html) and [Amazon Linux AMI Security Advisories](https://alas.aws.amazon.com/). Note that Docker Hub's vulnerability scanning for Amazon Linux is currently based on RPM versions, which does not reflect the state of backported patches for vulnerabilities.", "usageText": "## Supported architectures\n\namd64, arm64v8\n\n## Where can I run Amazon Linux container images?\n\nYou can run Amazon Linux container images in any Docker based environment. Examples include, your laptop, in Amazon EC2 instances, and ECS clusters.\n\n## How do I install a software package from Extras repository in Amazon Linux 2?\n\nAvailable packages can be listed with the `amazon-linux-extras` command. Packages can be installed with the `amazon-linux-extras install <package>` command. Example: `amazon-linux-extras install rust1`\n\n## Will updates be available for Amazon Linux containers?\n\nSimilar to the Amazon Linux images for Amazon EC2 and on-premises use, Amazon Linux container images will get ongoing updates from Amazon in the form of security updates, bug fix updates, and other enhancements. Security bulletins for Amazon Linux are available at https://alas.aws.amazon.com/\n\n## Will AWS Support the current version of Amazon Linux going forward?\n\nYes; in order to avoid any disruption to your existing applications and to facilitate migration to Amazon Linux 2, AWS will provide regular security updates for Amazon Linux 2018.03 AMI and container image for 2 years after the final LTS build is announced. You can also use all your existing support channels such as AWS Support and Amazon Linux Discussion Forum to continue to submit support requests." } }Pour plus d’informations, consultez Creating a public repository et Repository catalog data dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez CreateRepository
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser delete-repository-policy.
- AWS CLI
-
Pour supprimer une politique de référentiel d’un registre public
L’exemple
delete-repository-policysuivant montre comment supprimer la politique du référentiel public ECR dans votre compte AWS.aws ecr-public delete-repository-policy \ --repository-nameproject-a/nginx-web-app\ --regionus-east-1Sortie :
{ "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "policyText": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"AllowPush\",\n \"Effect\" : \"Allow\",\n \"Principal\" : {\n \"AWS\" : [ \"arn:aws:iam:"123456789012":user/eksuser1\", \"arn:aws:iam:"123456789012":user/admin\" ]\n },\n \"Action\" : [ \"ecr-public:BatchCheckLayerAvailability\", \"ecr-public:PutImage\", \"ecr-public:InitiateLayerUpload\", \"ecr-public:UploadLayerPart\", \"ecr-public:CompleteLayerUpload\" ]\n } ]\n}" }Pour plus d’informations, consultez Deleting a public repository policy statement dans le Guide de l’utilisateur Amazon ECR.
-
Pour plus de détails sur l’API, consultez DeleteRepositoryPolicy
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser delete-repository.
- AWS CLI
-
Pour supprimer un référentiel d’un registre public
L’exemple
delete-repositorysuivant supprime un référentiel nomméproject-a/nginx-web-appde votre registre public.aws ecr-public delete-repository \ --repository-nameproject-a/nginx-web-appSortie :
{ "repository": { "repositoryArn": "arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app", "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "repositoryUri": "public.ecr.aws/public-registry-custom-alias/project-a/nginx-web-app", "createdAt": "2024-07-01T22:14:50.103000+00:00" } }Pour plus d’informations, consultez Suppression d’un référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez DeleteRepository
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-image-tags.
- AWS CLI
-
Exemple 1 : pour décrire les détails des balises d’image dans un référentiel public
L’exemple
describe-image-tagssuivant décrit imagetags dans l’exemple de référentielproject-a/nginx-web-app.aws ecr-public describe-image-tags \ --repository-nameproject-a/nginx-web-app\ --regionus-east-1Sortie :
{ "imageTagDetails": [ { "imageTag": "latest", "createdAt": "2024-07-10T22:29:00-05:00", "imageDetail": { "imageDigest": "sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2", "imageSizeInBytes": 121956548, "imagePushedAt": "2024-07-10T22:29:00-05:00", "imageManifestMediaType": "application/vnd.docker.distribution.manifest.v2+json", "artifactMediaType": "application/vnd.docker.container.image.v1+json" } } ] }-
Pour plus de détails sur l’API, consultez DescribeImageTags
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-images.
- AWS CLI
-
Exemple 1 : pour décrire des images dans un référentiel de registre public
L’exemple
describe-imagessuivant décrit les détails des images d’un référentiel nomméproject-a/nginx-web-appdans un registre public.aws ecr-public describe-images \ --repository-nameproject-a/nginx-web-app\ --regionus-east-1Sortie :
{ "imageDetails": [ { "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "imageDigest": "sha256:0d8c93e72e82fa070d49565c00af32abbe8ddfd7f75e39f4306771ae0628c7e8", "imageTags": [ "temp1.0" ], "imageSizeInBytes": 123184716, "imagePushedAt": "2024-07-23T11:32:49-05:00", "imageManifestMediaType": "application/vnd.docker.distribution.manifest.v2+json", "artifactMediaType": "application/vnd.docker.container.image.v1+json" }, { "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "imageDigest": "sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2", "imageTags": [ "temp2.0" ], "imageSizeInBytes": 121956548, "imagePushedAt": "2024-07-23T11:39:38-05:00", "imageManifestMediaType": "application/vnd.docker.distribution.manifest.v2+json", "artifactMediaType": "application/vnd.docker.container.image.v1+json" }, { "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "imageDigest": "sha256:f7a86a0760e2f8d7eff07e515fc87bf4bac45c35376c06f9a280f15ecad6d7e0", "imageTags": [ "temp3.0", "latest" ], "imageSizeInBytes": 232108879, "imagePushedAt": "2024-07-22T00:54:34-05:00", "imageManifestMediaType": "application/vnd.docker.distribution.manifest.v2+json", "artifactMediaType": "application/vnd.docker.container.image.v1+json" } ] }Pour plus d’informations, consultez Description d’une image dans un référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour décrire les images du référentiel en triant imageTags et imagePushedAt
L’exemple
describe-imagessuivant décrit les images d’un référentiel nommé project-a/nginx-web-app dans un registre public.aws ecr-public describe-images \ --repository-nameproject-a/nginx-web-app\ --query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[*]' \ --outputtextSortie :
temp3.0 latest temp1.0 temp2.0Exemple 3 : pour décrire les images du référentiel afin de générer les deux dernières balises d’image insérées dans le référentiel
L’exemple
describe-imagessuivant obtient les informations sur imagetags à partir du référentiel nomméproject-a/nginx-web-appdans un registre public et interroge le résultat pour n’afficher que les deux premiers enregistrements.aws ecr-public describe-images \ --repository-nameproject-a/nginx-web-app\ --query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[*] | [0:2]' \ --outputtextSortie :
temp3.0 latest temp1.0-
Pour plus de détails sur l’API, consultez DescribeImages
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-registries.
- AWS CLI
-
Pour décrire tous les registres d’un registre public
L’exemple
describe-registriessuivant décrit tous les registres de votre compte.aws ecr-public describe-registriesSortie :
{ "registries": [ { "registryId": "123456789012", "registryArn": "arn:aws:ecr-public::123456789012:registry/123456789012", "registryUri": "public.ecr.aws/publicregistrycustomalias", "verified": false, "aliases": [ { "name": "publicregistrycustomalias", "status": "ACTIVE", "primaryRegistryAlias": true, "defaultRegistryAlias": true } ] } ] }-
Pour plus de détails sur l’API, consultez DescribeRegistries
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-repository.
- AWS CLI
-
Exemple 1 : pour décrire un référentiel dans un registre public
L’exemple
describe-repositoriessuivant décrit un référentiel nomméproject-a/nginx-web-appdans un registre public.aws ecr-public describe-repositories \ --repository-nameproject-a/nginx-web-appSortie :
{ "repositories": [ { "repositoryArn": "arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app", "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "repositoryUri": "public.ecr.aws/public-registry-custom-alias/project-a/nginx-web-app", "createdAt": "2024-07-07T00:07:56.526000-05:00" } ] }Exemple 2 : pour décrire tous les référentiels d’un registre public dans une table
L’exemple
describe-repositoriessuivant décrit tous les référentiels d’un registre public, puis affiche leurs noms sous forme de table.aws ecr-public describe-repositories \ --regionus-east-1\ --outputtable\ --query"repositories[*].repositoryName"Sortie :
----------------------------- | DescribeRepositories | +---------------------------+ | project-a/nginx-web-app | | nginx | | myfirstrepo1 | | helm-test-chart | | test-ecr-public | | nginx-web-app | | sample-repo | +---------------------------+-
Pour plus de détails sur l’API, consultez DescribeRepository
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser get-authorization-token.
- AWS CLI
-
Exemple 1 : pour récupérer un jeton d’autorisation pour n’importe quel registre public Amazon ECR auquel le principal IAM a accès
L’exemple
get-authorization-tokensuivant obtient un jeton d’autorisation à l’aide de l’AWS CLI et le définit comme variable d’environnement.aws ecr-public get-authorization-token \ --regionus-east-1Sortie :
{ "authorizationData": { "authorizationToken": "QVdTOmV5SndZWGxzYjJKJFHDSFKJHERWUY65IOU36TRYEGFNSDLRIUOTUYTHJKLDFGOcmFUQk9OSFV2UVV4a0x6Sm1ZV0Z6TDFndlZtUjJSVmgxVEVObU9IZEdTWEZxU210c1JUQm5RWGxOUVV4NlNFUnROWG92ZWtGbWJFUjRkbWMyV0U5amFpczRNWGxTVkM5Tk5qWkVUM2RDYm05TVJqSkxjV3BsUVZvMmFYSm5iV1ZvVFdGSVRqVlFMMHN4VnpsTGVXbDFRWGRoTmpsbWFuQllhbVl6TkdGaGMwUjJha2xsYUhscWRscHZTRUpFVkVnNVQwNUdOVFpPY2xZclVFNVFVWGRSVFZvd04xUkhjVGxZZFVkQ1ZFZHBPRUptUzBVclYxQldMMjVMVkRsd2VFVlNSa1EzTWpWSlIxRkVWakJGZFZOVWEzaFBSVk5FWWpSc1lWZHZWMHBSYmxaMlJYWmhZekpaWVVOeFppdFlUa2xKU1RCdFUwdElVbXRJYlhGRk1WaFhNVTVRTkdwc1FYRlVNVWxZZUhkV05Xa3ZXWGd3ZUVZMWIyeE5VRU5QZEdSaWRHOU9lakZOZVdwTVZEUkNRVzlvYzNKSlpsRXhhR2cwWjJwRVJFVjNWalEzYjNCUmRIcEZUR1pYU1Rsc1kxSlNNbU5hUW5wRE1tOUpRMHR5Y1hkeGNXNDVMM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WFEVmtiRVpzVVZWc2QxbHJWbmxOYW13MVZWaG9UazVzVWpWbFJHaDZZMjFHVkZVeFFubFZXRTVLVGpCMGFXSlZNWGhpUjBwTVlUSTVNRTVVYXpCTE0wVnlWakF4VG1WSE5VcGtSa0pRVld4V1UwOVdVWGhqTVc4eVZraFdlVnA2VGsxV01tUnhVV3Q0ZEdGcVRsUk5hMnN5V2tSV2FtUkdVakZqVm5CUFVrUlNjR0pHUm1GbGFscDRXV2x6Y2xFd1VYcGhSRnBZVmtaU2FVNXVSVFZYYlVaVFpXdHdkVmRZVGpaVGEyaDBWMnhDVlU0elZrWlRSRUpIVlVWa2MwNVlhRFZsUkVwelQwWkNSbE5WY0ZGWFNFWXhaVmMxVEZsVE9VeFdhMGt4V1ROS1Rrd3pXazFpYkhCdFVrUldWRlJHVlhaTmJVazBZbFZzUkV3d2N6UldSV2MxVDBWa05tSXpiM2hXVms1V1ZtMDFiRkZUT1hoUFJVcHpUMGRzU2xaSVJrTkxNVTVFWWtaa05WWnViRmRYVjJRd1RXcG5kMVJWUmpCa1JYQkdZVlYwZFZNeU1VVlpWVTVQV25wa1ExZHFVbE5sUjBaRVlWVTFXbVZwY3pSTE1HTTFVbFZGTlZwRll6UlRSMVoxVFcxb05XTnJkRUpWZWxsM1RETmplbUV4WkdGU1JsWm9ZVVpzZEdWR2JFTlVNblJYVkRCNE5HUXlkRXhaTWxKTlYxZDBWRTB5YUZwaFJsazFVMGR3Y0ZGVk9YaGxhekV6VVZRd09VbHVNRDBpTENKMlpYSnphVzl1SWpvaU15SXNJblI1Y0dVaU9pSkVRVlJCWDB0RldTSXNJbVY0Y0dseVlYUnBiMjRpT2pFM01qRTVOVGMzTmpKOQ==", "expiresAt": "2024-07-25T21:37:26.301000-04:00" } }Pour plus d’informations, consultez Amazon ECR public registries dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour récupérer un jeton d’autorisation pour n’importe quel registre public Amazon ECR auquel le principal IAM a accès
L’exemple
get-authorization-tokensuivant obtient un jeton d’autorisation à l’aide de l’AWS CLI et le définit comme variable d’environnement.aws ecr-public get-authorization-token \ --regionus-east-1\ --output=text \ --query 'authorizationData.authorizationToken'Sortie :
QVdTOmV5SndZWGxzYjJKJFHDSFKJHERWUY65IOU36TRYEGFNSDLRIUOTUYTHJKLDFGOcmFUQk9OSFV2UVV4a0x6Sm1ZV0Z6TDFndlZtUjJSVmgxVEVObU9IZEdTWEZxU210c1JUQm5RWGxOUVV4NlNFUnROWG92ZWtGbWJFUjRkbWMyV0U5amFpczRNWGxTVkM5Tk5qWkVUM2RDYm05TVJqSkxjV3BsUVZvMmFYSm5iV1ZvVFdGSVRqVlFMMHN4VnpsTGVXbDFRWGRoTmpsbWFuQllhbVl6TkdGaGMwUjJha2xsYUhscWRscHZTRUpFVkVnNVQwNUdOVFpPY2xZclVFNVFVWGRSVFZvd04xUkhjVGxZZFVkQ1ZFZHBPRUptUzBVclYxQldMMjVMVkRsd2VFVlNSa1EzTWpWSlIxRkVWakJGZFZOVWEzaFBSVk5FWWpSc1lWZHZWMHBSYmxaMlJYWmhZekpaWVVOeFppdFlUa2xKU1RCdFUwdElVbXRJYlhGRk1WaFhNVTVRTkdwc1FYRlVNVWxZZUhkV05Xa3ZXWGd3ZUVZMWIyeE5VRU5QZEdSaWRHOU9lakZOZVdwTVZEUkNRVzlvYzNKSlpsRXhhR2cwWjJwRVJFVjNWalEzYjNCUmRIcEZUR1pYU1Rsc1kxSlNNbU5hUW5wRE1tOUpRMHR5Y1hkeGNXNDVMMmx4Um5GUlVGQnhjMVpQZG5WYUswOW9SQ3RPY0hwSlRsUk5lVXQyY0c1b1FsQjVZVEprVmtSdmJsQklOM05RU3pkNmQydERhMkZ5VmxSRmFVUndWVlE1ZGtsVWFXUkJWMFZEWVhoSFdXTk5VMXBTYTFreVRHZEVlVVZ0ZFRWRk4xTTVjRXBDUjBRMlYyTkdPVWhGWkVweVVGcEVaRFJxZUVablkwNXFaamh5YkVKWmJGSTNOVzFXSzFjd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2x6Y2xFd1VYcGhSRnBZVmtaU2FVNXVSVFZYYlVaVFpXdHdkVmRZVGpaVGEyaDBWMnhDVlU0elZrWlRSRUpIVlVWa2MwNVlhRFZsUkVwelQwWkNSbE5WY0ZGWFNFWXhaVmMxVEZsVE9VeFdhMGt4V1ROS1Rrd3pXazFpYkhCdFVrUldWRlJHVlhaTmJVazBZbFZzUkV3d2N6UldSV2MxVDBWa05tSXpiM2hXVms1V1ZtMDFiRkZUT1hoUFJVcHpUMGRzU2xaSVJrTkxNVTVFWWtaa05WWnViRmRYVjJRd1RXcG5kMVJWUmpCa1JYQkdZVlYwZFZNeU1VVlpWVTVQV25wa1ExZHFVbE5sUjBaRVlWVTFXbVZwY3pSTE1HTTFVbFZGTlZwRll6UlRSMVoxVFcxb05XTnJkRUpWZWxsM1RETmplbUV4WkdGU1JsWm9ZVVpzZEdWR2JFTlVNblJYVkRCNE5HUXlkRXhaTWxKTlYxZDBWRTB5YUZwaFJsazFVMGR3Y0ZGVk9YaGxhekV6VVZRd09VbHVNRDBpTENKMlpYSnphVzl1SWpvaU15SXNJblI1Y0dVaU9pSkVRVlJCWDB0RldTSXNJbVY0Y0dseVlYUnBiMjRpT2pFM01qRTVOVGMzTmpKOQPour plus d’informations, consultez Amazon ECR public registries dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez GetAuthorizationToken
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser get-login-password.
- AWS CLI
-
Exemple 1 : pour authentifier le docker auprès d’un registre public Amazon ECR
L’exemple
get-login-passwordsuivant récupère et affiche un jeton d’authentification à l’aide de l’API GetAuthorizationToken que vous pouvez utiliser pour vous authentifier auprès d’un registre public Amazon ECR.aws ecr-public get-login-password \ --regionus-east-1|dockerlogin\ --usernameAWS\ --password-stdinpublic.ecr.awsCette commande ne produit aucune sortie dans le terminal, mais dirige la sortie vers Docker.
Pour plus d’informations, consultez Authentification auprès du registre public dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour authentifier le docker auprès de votre propre registre public Amazon ECR personnalisé
L’exemple
get-login-passwordsuivant récupère et affiche un jeton d’authentification à l’aide de l’API GetAuthorizationToken que vous pouvez utiliser pour vous authentifier auprès de votre propre registre public Amazon ECR.aws ecr-public get-login-password \ --region us-east-1 \ | docker login \ --username AWS \ --password-stdin public.ecr.aws/<your-public-registry-custom-alias>Cette commande ne produit aucune sortie dans le terminal, mais dirige la sortie vers Docker.
Pour plus d’informations, consultez Authentification auprès de votre propre registre public Amazon ECR dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez GetLoginPassword
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser get-registry-catalog-data.
- AWS CLI
-
Pour récupérer les métadonnées du catalogue pour un registre ECR public
L’exemple
get-registry-catalog-datasuivant récupère les métadonnées du catalogue pour un registre ECR public.aws ecr-public get-registry-catalog-data \ --regionus-east-1Sortie :
{ "registryCatalogData": { "displayName": "YourCustomPublicRepositoryalias" } }-
Pour plus de détails sur l’API, consultez GetRegistryCatalogData
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser get-repository-catalog-data.
- AWS CLI
-
Pour récupérer les métadonnées du catalogue pour un référentiel dans un registre public
L’exemple
get-repository-catalog-datasuivant répertorie les métadonnées du catalogue pour le référentielproject-a/nginx-web-appdans un registre public.aws ecr-public get-repository-catalog-data \ --repository-nameproject-a/nginx-web-app\ --regionus-east-1Sortie :
{ "catalogData": { "description": "My project-a ECR Public Repository", "architectures": [ "ARM", "ARM 64", "x86", "x86-64" ], "operatingSystems": [ "Linux" ], "logoUrl": "https://d3g9o9u8re44ak.cloudfront.net/logo/491d3846-8f33-4d8b-a10c-c2ce271e6c0d/4f09d87c-2569-4916-a932-5c296bf6f88a.png", "aboutText": "## Quick reference\n\nMaintained <truncated>", "usageText": "## Supported architectures\n\namd64, arm64v8\n\n## <truncated>" } }Pour plus d’informations, consultez Repository catalog data dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez GetRepositoryCatalogData
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser get-repository-policy.
- AWS CLI
-
Pour obtenir une politique associée au référentiel
L’exemple
get-repository-policysuivant obtient une politique associée au référentiel.aws ecr-public get-repository-policy \ --repository-nameproject-a/nginx-web-app\ --regionus-east-1Sortie :
{ "registryId": "123456789012", "repositoryName": "project-a/nginx-web-app", "policyText": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"AllowPush\",\n \"Effect\" : \"Allow\",\n \"Principal\" : {\n \"AWS\" : [ \"arn:aws:iam::123456789012:user/eksuser1\", \"arn:aws:iam::123456789012:user/admin\" ]\n },\n \"Action\" : [ \"ecr-public:BatchCheckLayerAvailability\", \"ecr-public:PutImage\", \"ecr-public:InitiateLayerUpload\", \"ecr-public:UploadLayerPart\", \"ecr-public:CompleteLayerUpload\" ]\n } ]\n}" }Pour plus d’informations, consultez Use GetRepositoryPolicy with an AWS SDK or CLI dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez GetRepositoryPolicy
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser list-tags-for-resource.
- AWS CLI
-
Pour répertorier les balises d’un référentiel public dans un registre public
L’exemple
list-tags-for-resourcesuivant répertorie les balises d’une ressource nomméeproject-a/nginx-web-appdans un registre public.aws ecr-public list-tags-for-resource \ --resource-arnarn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app\ --regionus-east-1Sortie :
{ "tags": [ { "Key": "Environment", "Value": "Prod" }, { "Key": "stack", "Value": "dev1" }, { "Key": "Name", "Value": "project-a/nginx-web-app" } ] }Pour plus d’informations, consultez Répertorier les balises d’un référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez ListTagsForResource
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser put-registry-catalog-data.
- AWS CLI
-
Pour créer ou mettre à jour les métadonnées du catalogue pour un registre ECR public
L’exemple
put-registry-catalog-datasuivant crée ou met à jour les métadonnées du catalogue pour un registre ECR public. Seuls les comptes dotés du badge de compte vérifié peuvent avoir un nom d’affichage dans le registre.aws ecr-public put-registry-catalog-data \ --regionus-east-1\ --display-name<YourCustomPublicRepositoryalias>Sortie :
{ "registryCatalogData": { "displayName": "YourCustomPublicRepositoryalias" } }-
Pour plus de détails sur l’API, consultez PutRegistryCatalogData
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser put-repository-catalog-data.
- AWS CLI
-
Pour créer ou mettre à jour les données du catalogue pour un référentiel dans un registre public
L’exemple
put-repository-catalog-datasuivant crée ou met à jour les données de catalogue pour le référentiel nommé project-a/nginx-web-app dans un registre public, avec les informations concernant logoImageBlob, aboutText, usageText et les balises.aws ecr-public put-repository-catalog-data \ --repository-nameproject-a/nginx-web-app\ --cli-input-jsonfile://repository-catalog-data.json\ --regionus-east-1Contenu de
repository-catalog-data.json:{ "repositoryName": "project-a/nginx-web-app", "catalogData": { "description": "My project-a ECR Public Repository", "architectures": [ "ARM", "ARM 64", "x86", "x86-64" ], "operatingSystems": [ "Linux" ], "logoImageBlob": "iVBORw0KGgoA<<truncated-for-better-reading>>ErkJggg==", "aboutText": "## Quick reference.", "usageText": "## Supported architectures are as follows." } }Sortie :
{ "catalogData": { "description": "My project-a ECR Public Repository", "architectures": [ "ARM", "ARM 64", "x86", "x86-64" ], "operatingSystems": [ "Linux" ], "logoUrl": "https://d3g9o9u8re44ak.cloudfront.net/logo/df86cf58-ee60-4061-b804-0be24d97ccb1/4a9ed9b2-69e4-4ede-b924-461462d20ef0.png", "aboutText": "## Quick reference.", "usageText": "## Supported architectures are as follows." } }Pour plus d’informations, consultez Repository catalog data dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez PutRepositoryCatalogData
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser set-repository-policy.
- AWS CLI
-
Exemple 1 : pour définir une politique de référentiel afin d’autoriser une extraction au niveau du référentiel
L’exemple
set-repository-policysuivant applique une politique de référentiel ECR public au référentiel spécifié afin de contrôler les autorisations d’accès.aws ecr-public set-repository-policy \ --repository-nameproject-a/nginx-web-app\ --policy-textfile://my-repository-policy.jsonContenu de
my-repository-policy.json:{ "Version":"2012-10-17", "Statement" : [ { "Sid" : "allow public pull", "Effect" : "Allow", "Principal" : "*", "Action" : [ "ecr:BatchCheckLayerAvailability", "ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer" ] } ] }Sortie :
{ "registryId": "12345678901", "repositoryName": "project-a/nginx-web-app", "policyText": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"allow public pull\",\n \"Effect\" : \"Allow\",\n \"Principal\" : \"*\",\n \"Action\" : [ \"ecr:BatchCheckLayerAvailability\", \"ecr:BatchGetImage\", \"ecr:GetDownloadUrlForLayer\" ]\n } ]\n}" }Pour plus d’informations, consultez Définir une instruction de politique de référentiel dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour définir une politique de référentiel afin d’autoriser un utilisateur IAM de votre compte à envoyer des images
L’exemple
set-repository-policysuivant permet à un utilisateur IAM de votre compte de transférer des images vers un référentiel ECR de votre compte AWS en utilisant le fichier d’entrée nomméfile://my-repository-policy.jsoncomme texte de politique.aws ecr-public set-repository-policy \ --repository-nameproject-a/nginx-web-app\ --policy-textfile://my-repository-policy.jsonContenu de
my-repository-policy.json:{ "Version":"2012-10-17", "Statement": [ { "Sid": "AllowPush", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::account-id:user/push-pull-user-1", "arn:aws:iam::account-id:user/push-pull-user-2" ] }, "Action": [ "ecr-public:BatchCheckLayerAvailability", "ecr-public:PutImage", "ecr-public:InitiateLayerUpload", "ecr-public:UploadLayerPart", "ecr-public:CompleteLayerUpload" ] } ] }Sortie :
{ "registryId": "12345678901", "repositoryName": "project-a/nginx-web-app", "policyText": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"AllowPush\",\n \"Effect\" : \"Allow\",\n \"Principal\" : {\n \"AWS\" : [ \"arn:aws:iam::12345678901:user/admin\", \"arn:aws:iam::12345678901:user/eksuser1\" ]\n },\n \"Action\" : [ \"ecr-public:BatchCheckLayerAvailability\", \"ecr-public:PutImage\", \"ecr-public:InitiateLayerUpload\", \"ecr-public:UploadLayerPart\", \"ecr-public:CompleteLayerUpload\" ]\n } ]\n}" }Pour plus d’informations, consultez Définir une instruction de politique de référentiel dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 3 : pour définir une politique de référentiel afin d’autoriser un utilisateur IAM d’un autre compte à envoyer des images
L’exemple
set-repository-policysuivant permet à un compte spécifique d’envoyer des images en utilisant le fichier d’entrée CLI file://my-repository-policy.json dans votre compte AWS.aws ecr-public set-repository-policy \ --repository-nameproject-a/nginx-web-app\ --policy-textfile://my-repository-policy.jsonContenu de
my-repository-policy.json:{ "Version":"2012-10-17", "Statement": [ { "Sid": "AllowCrossAccountPush", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::other-or-same-account-id:role/RoleName" }, "Action": [ "ecr-public:BatchCheckLayerAvailability", "ecr-public:PutImage", "ecr-public:InitiateLayerUpload", "ecr-public:UploadLayerPart", "ecr-public:CompleteLayerUpload" ] } ] }Sortie :
{ "registryId": "12345678901", "repositoryName": "project-a/nginx-web-app", "policyText": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"AllowCrossAccountPush\",\n \"Effect\" : \"Allow\",\n \"Principal\" : {\n \"AWS\" : \"arn:aws:iam::12345678901:role/RoleName\"\n },\n \"Action\" : [ \"ecr-public:BatchCheckLayerAvailability\", \"ecr-public:PutImage\", \"ecr-public:InitiateLayerUpload\", \"ecr-public:UploadLayerPart\", \"ecr-public:CompleteLayerUpload\" ]\n } ]\n}" }Pour plus d’informations, consultez Exemples de politiques de référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez SetRepositoryPolicy
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser tag-resource.
- AWS CLI
-
Exemple 1 : pour baliser un référentiel public existant dans un registre public
L’exemple
tag-resourcesuivant balise un référentiel nomméproject-a/nginx-web-appdans un registre public.aws ecr-public tag-resource \ --resource-arnarn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app\ --tagsKey=stack,Value=dev\ --regionus-east-1Pour plus d’informations, consultez Utilisation de balises pour un référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
Exemple 2 : pour baliser un référentiel public existant avec plusieurs balises dans un registre public
L’exemple
tag-resourcesuivant balise un référentiel existant avec plusieurs balises.aws ecr-public tag-resource \ --resource-arnarn:aws:ecr-public::890517186334:repository/project-a/nginx-web-app\ --tagsKey=key1,Value=value1Key=key2,Value=value2Key=key3,Value=value3\ --regionus-east-1Pour plus d’informations, consultez Utilisation de balises pour un référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez TagResource
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser untag-resource.
- AWS CLI
-
Exemple 1 : pour supprimer une balise d’un référentiel public existant dans un registre public
L’exemple
untag-resourcesuivant balise un référentiel nomméproject-a/nginx-web-appdans un registre public.aws ecr-public untag-resource \ --resource-arnarn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app\ --tag-keysstack\ --regionus-east-1Cette commande ne produit aucune sortie.
Pour plus d’informations, consultez Utilisation de balises pour un référentiel public dans le Guide de l’utilisateur Amazon ECR Public.
-
Pour plus de détails sur l’API, consultez UntagResource
dans la Référence des commandes de l’AWS CLI.
-