Exemples d'Amazon ECR Public utilisant AWS CLI - AWS Command Line Interface

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

Exemples d'Amazon ECR Public utilisant AWS CLI

Les exemples de code suivants vous montrent comment effectuer des actions et implémenter des scénarios courants à l' AWS Command Line Interface aide d'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 façon de configurer et d'exécuter le code en contexte.

Rubriques

Actions

L'exemple de code suivant montre comment utiliserbatch-delete-image.

AWS CLI

Exemple 1 : pour supprimer une image à l'aide des identifiants de condensé d'image, l'image et toutes ses balises sont supprimées dans un référentiel d'un registre public

L'batch-delete-imageexemple suivant supprime une image en spécifiant le condensé de l'image. :

aws ecr-public batch-delete-image \ --repository-name project-a/nginx-web-app \ --image-ids imageDigest=sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2

Sortie :

{ "imageIds": [ { "imageDigest": "sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2", "imageTag": "latest" } ], "failures": [] }

Pour plus d'informations, consultez la section Suppression d'une image dans un référentiel public dans le manuel Amazon ECR Public User Guide.

Exemple 2 : Supprimer une image en spécifiant la balise associée à l'image que vous souhaitez supprimer du référentiel.

L'batch-delete-imageexemple suivant supprime une image en spécifiant la balise associée au référentiel d'images nommé project-a/nginx-web-app dans un registre public. Si vous n'avez qu'un seul tag 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, et seule la balise sera supprimée du référentiel, pas l'image.

aws ecr-public batch-delete-image \ --repository-name project-a/nginx-web-app \ --image-ids imageTag=_temp

Sortie :

{ "imageIds": [ { "imageDigest": "sha256:f7a86a0760e2f8d7eff07e515fc87bf4bac45c35376c06f9a280f15ecad6d7e0", "imageTag": "_temp" } ], "failures": [] }

Pour plus d'informations, consultez la section Suppression d'une image dans un référentiel public dans le manuel Amazon ECR Public User Guide.

Exemple 3 : pour supprimer plusieurs images, vous pouvez spécifier plusieurs balises d'image ou résumés d'images dans la demande de dépôt dans un registre public.

L'batch-delete-imageexemple suivant supprime plusieurs images d'un référentiel nommé project-a/ nginx-web-app en spécifiant plusieurs balises d'image ou résumés d'images dans la demande.

aws ecr-public batch-delete-image \ --repository-name project-a/nginx-web-app \ --image-ids imageTag=temp2.0 imageDigest=sha256:47ba980bc055353d9c0af89b1894f68faa43ca93856917b8406316be86f01278

Sortie :

{ "imageIds": [ { "imageDigest": "sha256:47ba980bc055353d9c0af89b1894f68faa43ca93856917b8406316be86f01278" }, { "imageDigest": "sha256:f7a86a0760e2f8d7eff07e515fc87bf4bac45c35376c06f9a280f15ecad6d7e0", "imageTag": "temp2.0" } ], "failures": [] }

Pour plus d'informations, consultez la section Suppression d'une image dans un référentiel public dans le manuel Amazon ECR Public User Guide.

Exemple 4 : Pour supprimer une image dans Cross AWS Account à l'aide des identifiants registry-id et imagedigest, l'image et toutes ses balises sont supprimées dans un référentiel d'un registre public

L'batch-delete-imageexemple suivant supprime une image en spécifiant le résumé de l'image dans le AWS compte croisé. :

aws ecr-public batch-delete-image \ --registry-id 123456789098 \ --repository-name project-a/nginx-web-app \ --image-ids imageDigest=sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2 \ --region us-east-1

Sortie :

{ "imageIds": [ { "imageDigest": "sha256:b1f9deb5fe3711a3278379ebbcaefbc5d70a2263135db86bd27a0dae150546c2", "imageTag": "temp2.0" } ], "failures": [] }

Pour plus d'informations, consultez la section Suppression d'une image dans un référentiel public dans le manuel Amazon ECR Public User Guide.

  • Pour plus de détails sur l'API, reportez-vous BatchDeleteImageà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utilisercreate-repository.

AWS CLI

Exemple 1 : pour créer un dépôt dans un registre public

L'create-repositoryexemple suivant crée un dépôt nommé project-a/ nginx-web-app dans un registre public.

aws ecr-public create-repository \ --repository-name project-a/nginx-web-app

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:08:55.131000+00:00" }, "catalogData": {} }

Pour plus d'informations, consultez la section Création d'un référentiel public dans le manuel Amazon ECR Public User Guide.

Exemple 2 : créer un référentiel 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

L'create-repositoryexemple suivant 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-name project-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 la section Création d'un référentiel public dans le manuel Amazon ECR Public User Guide.

Exemple 3 : pour créer un référentiel dans un registre public, avec des informations sur AboutText logoImageBlob, UsageText et les balises

L'create-repositoryexemple suivant crée un référentiel nommé project-a/ nginx-web-app dans un registre public, avec les informations AboutText, logoImageBlob UsageText et les balises.

aws ecr-public create-repository \ --cli-input-json file://myfile.json

Contenu 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 la section Création d'un référentiel public dans le guide de l'utilisateur public Amazon ECR et les données du catalogue du référentiel dans le guide de l'utilisateur public d'Amazon ECR.

  • Pour plus de détails sur l'API, reportez-vous CreateRepositoryà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserdelete-repository-policy.

AWS CLI

Pour supprimer une politique de référentiel dans un registre public

L'delete-repository-policyexemple suivant montre comment supprimer la politique de dépôt pour le référentiel public ECR de votre AWS compte.

aws ecr-public delete-repository-policy \ --repository-name project-a/nginx-web-app \ --region us-east-1

Sortie :

{ "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 la section Suppression d'une déclaration de politique relative à un référentiel public dans le manuel Amazon ECR Public User Guide.

  • Pour plus de détails sur l'API, reportez-vous DeleteRepositoryPolicyà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserdelete-repository.

AWS CLI

Pour supprimer un dépôt dans un registre public

L'delete-repositoryexemple suivant supprime un dépôt nommé project-a/nginx-web-app dans votre registre public.

aws ecr-public delete-repository \ --repository-name project-a/nginx-web-app

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-01T22:14:50.103000+00:00" } }

Pour plus d'informations, consultez Supprimer un référentiel public dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous DeleteRepositoryà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserdescribe-image-tags.

AWS CLI

Exemple 1 : pour décrire les détails des balises d'image dans le référentiel public

L'describe-image-tagsexemple suivant décrit les imagetags dans le référentiel project-a/nginx-web-app d'exemples.

aws ecr-public describe-image-tags \ --repository-name project-a/nginx-web-app \ --region us-east-1

Sortie :

{ "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, reportez-vous DescribeImageTagsà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserdescribe-images.

AWS CLI

Exemple 1 : pour décrire des images dans un référentiel de registre public

L'describe-imagesexemple suivant décrit ImagesDetails dans un référentiel nommé project-a/nginx-web-app dans un registre public.

aws ecr-public describe-images \ --repository-name project-a/nginx-web-app \ --region us-east-1

Sortie :

{ "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 Décrire une image dans un référentiel public dans Amazon ECR Public.

Exemple 2 : Pour décrire les images du référentiel en triant ImageTags & imagePushedAt

L'describe-imagesexemple suivant décrit les images d'un dépôt nommé project-a/ nginx-web-app dans un registre public.

aws ecr-public describe-images \ --repository-name project-a/nginx-web-app \ --query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[*]' \ --output text

Sortie :

temp3.0 latest temp1.0 temp2.0

Exemple 3 : pour décrire les images du référentiel afin de générer les 2 dernières balises d'image insérées dans le référentiel

L'describe-imagesexemple suivant obtient les détails des imagetags à partir du référentiel nommé project-a/nginx-web-app dans un registre public et interroge le résultat pour n'afficher que les deux premiers enregistrements.

aws ecr-public describe-images \ --repository-name project-a/nginx-web-app \ --query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[*] | [0:2]' \ --output text

Sortie :

temp3.0 latest temp1.0
  • Pour plus de détails sur l'API, reportez-vous DescribeImagesà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserdescribe-registries.

AWS CLI

Décrire tous les registres d'un registre public

L'describe-registriesexemple suivant décrit tous les registres de votre compte.

aws ecr-public describe-registries

Sortie :

{ "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, reportez-vous DescribeRegistriesà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserdescribe-repository.

AWS CLI

Exemple 1 : pour décrire un dépôt dans un registre public

L'describe-repositoriesexemple suivant décrit un référentiel nommé project-a/nginx-web-app dans un registre public.

aws ecr-public describe-repositories \ --repository-name project-a/nginx-web-app

Sortie :

{ "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 un tableau

L'describe-repositoriesexemple suivant décrit tous les référentiels d'un registre public, puis affiche les noms des référentiels sous forme de tableau.

aws ecr-public describe-repositories \ --region us-east-1 \ --output table \ --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, reportez-vous DescribeRepositoryà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserget-authorization-token.

AWS CLI

Exemple 1 : pour récupérer un jeton d'autorisation pour tout registre public Amazon ECR auquel le principal IAM a accès

L'get-authorization-tokenexemple suivant obtient un jeton d'autorisation avec la AWS CLI et le définit comme une variable d'environnement.

aws ecr-public get-authorization-token \ --region us-east-1

Sortie :

{ "authorizationData": { "authorizationToken": "QVdTOmV5SndZWGxzYjJKJFHDSFKJHERWUY65IOU36TRYEGFNSDLRIUOTUYTHJKLDFGOcmFUQk9OSFV2UVV4a0x6Sm1ZV0Z6TDFndlZtUjJSVmgxVEVObU9IZEdTWEZxU210c1JUQm5RWGxOUVV4NlNFUnROWG92ZWtGbWJFUjRkbWMyV0U5amFpczRNWGxTVkM5Tk5qWkVUM2RDYm05TVJqSkxjV3BsUVZvMmFYSm5iV1ZvVFdGSVRqVlFMMHN4VnpsTGVXbDFRWGRoTmpsbWFuQllhbVl6TkdGaGMwUjJha2xsYUhscWRscHZTRUpFVkVnNVQwNUdOVFpPY2xZclVFNVFVWGRSVFZvd04xUkhjVGxZZFVkQ1ZFZHBPRUptUzBVclYxQldMMjVMVkRsd2VFVlNSa1EzTWpWSlIxRkVWakJGZFZOVWEzaFBSVk5FWWpSc1lWZHZWMHBSYmxaMlJYWmhZekpaWVVOeFppdFlUa2xKU1RCdFUwdElVbXRJYlhGRk1WaFhNVTVRTkdwc1FYRlVNVWxZZUhkV05Xa3ZXWGd3ZUVZMWIyeE5VRU5QZEdSaWRHOU9lakZOZVdwTVZEUkN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Amazon ECR dans Amazon ECR Public.

Exemple 2 : pour récupérer un jeton d'autorisation pour tout registre public Amazon ECR auquel le principal IAM a accès

L'get-authorization-tokenexemple suivant obtient un jeton d'autorisation avec la AWS CLI et le définit comme une variable d'environnement.

aws ecr-public get-authorization-token \ --region us-east-1 \ --output=text \ --query 'authorizationData.authorizationToken'

Sortie :

QVdTOmV5SndZWGxzYjJKJFHDSFKJHERWUY65IOU36TRYEGFNSDLRIUOTUYTHJKLDFGOcmFUQk9OSFV2UVV4a0x6Sm1ZV0Z6TDFndlZtUjJSVmgxVEVObU9IZEdTWEZxU210c1JUQm5RWGxOUVV4NlNFUnROWG92ZWtGbWJFUjRkbWMyV0U5amFpczRNWGxTVkM5Tk5qWkVUM2RDYm05TVJqSkxjV3BsUVZvMmFYSm5iV1ZvVFdGSVRqVlFMMHN4VnpsTGVXbDFRWGRoTmpsbWFuQllhbVl6TkdGaGMwUjJha2xsYUhscWRscHZTRUpFVkVnNVQwNUdOVFpPY2xZclVFNVFVWGRSVFZvd04xUkhjVGxZZFVkQ1ZFZHBPRUptUzBVclYxQldMMjVMVkRsd2VFVlNSa1EzTWpWSlIxRkVWakJGZFZOVWEzaFBSVk5FWWpSc1lWZHZWMHBSYmxaMlJYWmhZekpaWVVOeFppdFlUa2xKU1RCdFUwdElVbXRJYlhGRk1WaFhNVTVRTkdwc1FYRlVNVWxZZUhkV05Xa3ZXWGd3ZUVZMWIyeE5VRU5QZEdSaWRHOU9lakZOZVdwTVZEUkNRVzlvYzNKSlpsRXhhR2cwWjJwRVJFVjNWalEzYjNCUmRIcEZUR1pYU1Rsc1kxSlNNbU5hUW5wRE1tOUpRMHR5Y1hkeGNXNDVMMmx4Um5GUlVGQnhjMVpQZG5WYUswOW9SQ3RPY0hwSlRsUk5lVXQyY0c1b1FsQjVZVEprVmtSdmJsQklOM05RU3pkNmQydERhMkZ5VmxSRmFVUndWVlE1ZGtsVWFXUkJWMFZEWVhoSFdXTk5VMXBTYTFreVRHZEVlVVZ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FdlVnA2VGsxV01tUnhVV3Q0ZEdGcVRsUk5hMnN5V2tSV2FtUkdVakZqVm5CUFVrUlNjR0pHUm1GbGFscDRXV2x6Y2xFd1VYcGhSRnBZVmtaU2FVNXVSVFZYYlVaVFpXdHdkVmRZVGpaVGEyaDBWMnhDVlU0elZrWlRSRUpIVlVWa2MwNVlhRFZsUkVwelQwWkNSbE5WY0ZGWFNFWXhaVmMxVEZsVE9VeFdhMGt4V1ROS1Rrd3pXazFpYkhCdFVrUldWRlJHVlhaTmJVazBZbFZzUkV3d2N6UldSV2MxVDBWa05tSXpiM2hXVms1V1ZtMDFiRkZUT1hoUFJVcHpUMGRzU2xaSVJrTkxNVTVFWWtaa05WWnViRmRYVjJRd1RXcG5kMVJWUmpCa1JYQkdZVlYwZFZNeU1VVlpWVTVQV25wa1ExZHFVbE5sUjBaRVlWVTFXbVZwY3pSTE1HTTFVbFZGTlZwRll6UlRSMVoxVFcxb05XTnJkRUpWZWxsM1RETmplbUV4WkdGU1JsWm9ZVVpzZEdWR2JFTlVNblJYVkRCNE5HUXlkRXhaTWxKTlYxZDBWRTB5YUZwaFJsazFVMGR3Y0ZGVk9YaGxhekV6VVZRd09VbHVNRDBpTENKMlpYSnphVzl1SWpvaU15SXNJblI1Y0dVaU9pSkVRVlJCWDB0RldTSXNJbVY0Y0dseVlYUnBiMjRpT2pFM01qRTVOVGMzTmpKOQ

Pour plus d'informations, consultez les registres publics Amazon ECR dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous GetAuthorizationTokenà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserget-login-password.

AWS CLI

Exemple 1 : pour authentifier le docker auprès d'un registre public Amazon ECR

L'get-login-passwordexemple suivant récupère et affiche un jeton d'authentification à l'aide de l' GetAuthorizationToken API que vous pouvez utiliser pour vous authentifier auprès d'un registre public Amazon ECR.

aws ecr-public get-login-password \ --region us-east-1 | docker login \ --username AWS \ --password-stdin public.ecr.aws

Cette commande ne produit aucune sortie dans le terminal mais dirige la sortie vers Docker.

Pour plus d'informations, consultez Authentifier auprès du registre public dans Amazon ECR Public.

Exemple 2 : pour authentifier docker auprès de votre propre registre public AmazonECR personnalisé

L'get-login-passwordexemple suivant récupère et affiche un jeton d'authentification à l'aide de l' GetAuthorizationToken API que vous pouvez utiliser pour vous authentifier auprès de votre propre registre public Amazon ECR personnalisé.

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 Authentifiez-vous auprès de votre propre Amazon ECR Public dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous GetLoginPasswordà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserget-registry-catalog-data.

AWS CLI

Pour récupérer les métadonnées du catalogue pour un registre ECR public

Ce qui suit get-registry-catalog-data permet de récupérer les métadonnées du catalogue pour un registre public ECR.

aws ecr-public get-registry-catalog-data \ --region us-east-1

Sortie :

{ "registryCatalogData": { "displayName": "YourCustomPublicRepositoryalias" } }
  • Pour plus de détails sur l'API, reportez-vous GetRegistryCatalogDataà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserget-repository-catalog-data.

AWS CLI

Pour récupérer les métadonnées d'un catalogue pour un référentiel dans un registre public

L'get-repository-catalog-dataexemple suivant répertorie les métadonnées du catalogue pour le référentiel project-a/nginx-web-app dans un registre public.

aws ecr-public get-repository-catalog-data \ --repository-name project-a/nginx-web-app \ --region us-east-1

Sortie :

{ "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 les données du catalogue du référentiel dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous GetRepositoryCatalogDataà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserget-repository-policy.

AWS CLI

Pour obtenir une politique de dépôt associée au référentiel

L'get-repository-policyexemple suivant permet d'obtenir une politique de dépôt associée au dépôt.

aws ecr-public get-repository-policy \ --repository-name project-a/nginx-web-app \ --region us-east-1

Sortie :

{ "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 la section Utilisation GetRepositoryPolicy avec un AWS SDK ou une CLI dans le manuel Amazon ECR Public User Guide.

  • Pour plus de détails sur l'API, reportez-vous GetRepositoryPolicyà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserlist-tags-for-resource.

AWS CLI

Pour répertorier les balises d'un dépôt public dans un registre public

L'list-tags-for-resourceexemple suivant répertorie les balises d'une ressource nommée project-a/nginx-web-app dans un registre public.

aws ecr-public list-tags-for-resource \ --resource-arn arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app \ --region us-east-1

Sortie :

{ "tags": [ { "Key": "Environment", "Value": "Prod" }, { "Key": "stack", "Value": "dev1" }, { "Key": "Name", "Value": "project-a/nginx-web-app" } ] }

Pour plus d'informations, consultez Lister les balises d'un référentiel public dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous ListTagsForResourceà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserput-registry-catalog-data.

AWS CLI

Pour créer ou mettre à jour les métadonnées du catalogue pour un registre ECR public

Ce qui suit put-registry-catalog-data crée ou met à jour les métadonnées du catalogue pour un registre public ECR. 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 \ --region us-east-1 \ --display-name <YourCustomPublicRepositoryalias>

Sortie :

{ "registryCatalogData": { "displayName": "YourCustomPublicRepositoryalias" } }
  • Pour plus de détails sur l'API, reportez-vous PutRegistryCatalogDataà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserput-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'put-repository-catalog-dataexemple suivant crée ou met à jour des données de catalogue pour le référentiel nommé project-a/ nginx-web-app dans un registre public, ainsi que des informations sur AboutText, UsageText et les logoImageBlob balises.

aws ecr-public put-repository-catalog-data \ --repository-name project-a/nginx-web-app \ --cli-input-json file://repository-catalog-data.json \ --region us-east-1

Contenu 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 les données du catalogue du référentiel dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous PutRepositoryCatalogDataà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliserset-repository-policy.

AWS CLI

Exemple 1 : pour définir une politique de dépôt afin d'autoriser une extraction sur le référentiel

L'set-repository-policyexemple suivant applique une politique de référentiel public ECR au référentiel spécifié afin de contrôler les autorisations d'accès.

aws ecr-public set-repository-policy \ --repository-name project-a/nginx-web-app \ --policy-text file://my-repository-policy.json

Contenu de my-repository-policy.json :

{ "Version" : "2008-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 la section Définition d'une déclaration de politique de dépôt dans le manuel Amazon ECR Public User Guide.

Exemple 2 : pour définir une politique de référentiel afin d'autoriser un utilisateur IAM de votre compte à envoyer des images

L'set-repository-policyexemple suivant permet à un utilisateur IAM de votre compte de transférer des images vers un référentiel ECR de votre AWS compte en utilisant le fichier d'entrée file://my-repository-policy.json nommé texte de politique.

aws ecr-public set-repository-policy \ --repository-name project-a/nginx-web-app \ --policy-text file://my-repository-policy.json

Contenu de my-repository-policy.json :

{ "Version": "2008-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 la section Définition d'une déclaration de politique de dépôt dans le manuel Amazon ECR Public User Guide.

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'set-repository-policyexemple suivant permet à un compte spécifique d'envoyer des images en utilisant cli input file ://my-repository-policy.json dans votre AWS compte.

aws ecr-public set-repository-policy \ --repository-name project-a/nginx-web-app \ --policy-text file://my-repository-policy.json

Contenu de my-repository-policy.json :

{ "Version": "2008-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 les exemples de politiques relatives aux référentiels publics dans le manuel Amazon ECR Public User Guide.

  • Pour plus de détails sur l'API, reportez-vous SetRepositoryPolicyà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utilisertag-resource.

AWS CLI

Exemple 1 : Pour baliser un dépôt public existant dans un registre public

L'tag-resourceexemple suivant balise un référentiel nommé project-a/nginx-web-app dans un registre public.

aws ecr-public tag-resource \ --resource-arn arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app \ --tags Key=stack,Value=dev \ --region us-east-1

Pour plus d'informations, consultez Utilisation de balises pour un référentiel public dans Amazon ECR Public.

Exemple 2 : Pour baliser un référentiel public existant avec plusieurs balises dans un registre public.

L'tag-resourceexemple suivant ajoute plusieurs balises à un référentiel existant.

aws ecr-public tag-resource \ --resource-arn arn:aws:ecr-public::890517186334:repository/project-a/nginx-web-app \ --tags Key=key1,Value=value1 Key=key2,Value=value2 Key=key3,Value=value3 \ --region us-east-1

Pour plus d'informations, consultez Utilisation de balises pour un référentiel public dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous TagResourceà la section Référence des AWS CLI commandes.

L'exemple de code suivant montre comment utiliseruntag-resource.

AWS CLI

Exemple 1 : pour débaliser un dépôt public existant dans un registre public

L'untag-resourceexemple suivant balise un référentiel nommé project-a/nginx-web-app dans un registre public.

aws ecr-public untag-resource \ --resource-arn arn:aws:ecr-public::123456789012:repository/project-a/nginx-web-app \ --tag-keys stack \ --region us-east-1

Cette commande ne produit aucun résultat.

Pour plus d'informations, consultez Utilisation de balises pour un référentiel public dans Amazon ECR Public.

  • Pour plus de détails sur l'API, reportez-vous UntagResourceà la section Référence des AWS CLI commandes.