

# Amazon ECR Public images
<a name="public-images"></a>

Amazon ECR Public is a fully-managed service provided by AWS that allows you to store, manage, and deploy Docker images, Open Container Initiative (OCI) images, and OCI compatible artifacts in public repositories. You can use the Docker CLI and other compatible clients to push and pull images to and from your Amazon ECR public repositories. Once stored, you can easily deploy these container images to various environments like Amazon ECS, Amazon EKS, or on-premises infrastructure. 

Amazon ECR public provides features for managing the lifecycle of your container images, including tracking versions, applying tags, and controlling access to your public repositories. Amazon ECR public repositories are globally available, allowing you to distribute and consume container images from anywhere in the world.

**Important**  
Amazon ECR requires that users have permission to make calls to the `ecr-public:GetAuthorizationToken` and `sts:GetServiceBearerToken` API through an IAM policy before they can authenticate to a registry and push any images to an Amazon ECR repository.

**Topics**
+ [Pushing an image to a public repository in Amazon ECR public](docker-push-ecr-image.md)
+ [Pushing a multi-architecture image to a public repository in Amazon ECR public](docker-push-multi-architecture-image.md)
+ [Pushing a Helm chart to a public repository in Amazon ECR public](push-oci-artifact.md)
+ [Pulling an image from the Amazon ECR Public Gallery](docker-pull-ecr-image.md)
+ [Deleting an image in a public repository in Amazon ECR public](public-image-delete.md)
+ [Container image manifest formats in Amazon ECR public](image-manifest-formats.md)

# Pushing an image to a public repository in Amazon ECR public
<a name="docker-push-ecr-image"></a>

You can push your Docker images to an Amazon ECR public repository with the **docker push** command.

**Important**  
Amazon ECR requires that users have permission to make calls to the `ecr-public:GetAuthorizationToken` and `sts:GetServiceBearerToken` API through an IAM policy before they can authenticate to a registry and push any images to an Amazon ECR repository.

Amazon ECR Public also supports creating and pushing Docker manifest lists which are used for multi-architecture images. Each image referenced in a manifest list must already be pushed to your repository. For more information, see [Pushing a multi-architecture image to a public repository in Amazon ECR public](docker-push-multi-architecture-image.md).

**To push a Docker image to an Amazon ECR public repository**

1. Authenticate your Docker client to the Amazon ECR public registry to which you intend to push your image. Authentication tokens are valid for 12 hours. For more information, see [Registry authentication in Amazon ECR public](public-registry-auth.md).

1. If your public repository does not exist in the registry you intend to push to yet, create it. For more information, see [Creating an Amazon ECR public repository to store images](public-repository-create.md).

1. Identify the image to push. Run the **docker images** command to list the images on your system.

   ```
   docker images
   ```

   You can identify an image with the *repository:tag* value or the image ID in the resulting command output.

1. <a name="image-tag-step"></a>Tag your image with the Amazon ECR public registry, public repository, and optional image tag name combination to use. The public registry format is `public.ecr.aws/registry_alias`. The public repository name should match the repository that you created for your image. If you omit the image tag, we assume that the tag is `latest`.

   ```
   docker tag e9ae3c220b23 public.ecr.aws/registry_alias/my-web-app:image-tag
   ```

   For this example command, note the following:
   + Image ID is *e9ae3c220b23*
   + Public registry is `public.ecr.aws/registry_alias/`
   + Repository is *my-web-app*
   + Image tag is *image-tag*

1. <a name="image-push-step"></a>Push the image using the **docker push** command (again, (`my-web-app` is the name of the repository, and *image-tag* is the image tag):

   ```
   docker push public.ecr.aws/registry_alias/my-web-app:image-tag
   ```

1. (Optional) Apply any additional tags to your image and push those tags to Amazon ECR Public by repeating [Step 4](#image-tag-step) and [Step 5](#image-push-step). You can apply up to 1000 tags per image in Amazon ECR Public.

# Pushing a multi-architecture image to a public repository in Amazon ECR public
<a name="docker-push-multi-architecture-image"></a>

Amazon ECR Public supports creating and pushing Docker manifest lists which are used for multi-architecture images. A *manifest list* is a list of images that is created by specifying one or more image names. Typically the manifest list is created from images that serve the same function but for different operating systems or architectures, but this is not required. For more information, see [docker manifest](https://docs.docker.com/engine/reference/commandline/manifest/).

**Important**  
Your Docker CLI must have experimental features enabled to use this feature. For more information, see [Experimental features](https://docs.docker.com/engine/reference/commandline/cli/#experimental-features).

A manifest list can be pulled or referenced in an Amazon ECS task definition or Amazon EKS pod spec like other Amazon ECR Public images.

The following steps can be used to create and push a Docker manifest list to an Amazon ECR public repository. You must already have the images pushed to your public repository to reference in the Docker manifest. For information on pushing an image, see [Pushing an image to a public repository in Amazon ECR public](docker-push-ecr-image.md).

**To push a multi-architecture Docker image to an Amazon ECR public repository**

1. Authenticate your Docker client to the Amazon ECR public registry to which you intend to push your image. Authentication tokens are valid for 12 hours. For more information, see [Registry authentication in Amazon ECR public](public-registry-auth.md).

1. List the images in your public repository, confirming the image tags.

   ```
   aws ecr-public describe-images \
        --repository-name my-web-app
        --region us-east-1
   ```

1. Create the Docker manifest list. The `manifest create` command verifies that the referenced images are already in your public repository and creates the manifest locally.

   ```
   docker manifest create public.ecr.aws/registry_alias/my-web-app public.ecr.aws/registry_alias/my-web-app:image_one_tag public.ecr.aws/registry_alias/my-web-app:image_two
   ```

1. (Optional) Inspect the Docker manifest list. This enables you to confirm the size and digest for each image manifest referenced in the manifest list.

   ```
   docker manifest inspect public.ecr.aws/registry_alias/my-web-app
   ```

1. Push the Docker manifest list to your Amazon ECR public repository.

   ```
   docker manifest push public.ecr.aws/registry_alias/my-web-app
   ```

# Pushing a Helm chart to a public repository in Amazon ECR public
<a name="push-oci-artifact"></a>

Amazon ECR Public supports pushing Open Container Initiative (OCI) artifacts to your public repositories. To display this functionality, use the following steps to push a Helm chart to Amazon ECR Public.

**To push a Helm chart to an Amazon ECR public repository**

1. Install Helm version `3.8.0` or higher of the Helm client. These steps were written using Helm version `3.8.0`. For more information, see [Installing Helm](https://helm.sh/docs/intro/install/).

1. Use the following steps to create a test Helm chart. For more information, see [Helm Docs - Getting Started](https://helm.sh/docs/chart_template_guide/getting_started/).

   1. Create a Helm chart named `helm-test-chart` and clear the contents of the `templates` directory.

      ```
      helm create helm-test-chart
      rm -rf ./helm-test-chart/templates/*
      ```

   1. Create a ConfigMap in the `templates` folder.

      ```
      cd helm-test-chart/templates
      cat <<EOF > configmap.yaml
      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: helm-test-chart-configmap
      data:
        myvalue: "Hello World"
      EOF
      ```

1. Package the chart. The output will contain the filename of the packaged chart which you use when pushing the Helm chart.

   ```
   cd ..
   helm package helm-test-chart
   ```

   Output

   ```
   Successfully packaged chart and saved it to: /Users/username/helm-test-chart-0.1.0.tgz
   ```

1. Create a public repository to store your Helm chart. For more information, see [Creating an Amazon ECR public repository to store images](public-repository-create.md).

   ```
   aws ecr-public create-repository \
        --repository-name helm-test-chart \
        --region us-east-1
   ```

1. Authenticate your Helm client to the Amazon ECR public registry to which you intend to push your Helm chart. Authentication tokens are valid for 12 hours. For more information, see [Registry authentication in Amazon ECR public](public-registry-auth.md).

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

1. Push the Helm chart using the **helm push** command. The output should include the Amazon ECR repository URI and SHA digest.

   ```
   helm push helm-test-chart-0.1.0.tgz oci://public.ecr.aws/registry_alias
   ```

1. Describe your Helm chart.

   ```
   aws ecr-public describe-images \
        --repository-name helm-test-chart \
        --region us-east-1
   ```

   ```
   {
       "imageDetails": [
           {
               "registryId": "aws_account_id",
               "repositoryName": "helm-test-chart",
               "imageDigest": "sha256:f23ab9dc0fda33175e465bd694a5f4cade93eaf62715fa9390d9fEXAMPLE",
               "imageTags": [
                   "0.1.0"
               ],
               "imageSizeInBytes": 1636,
               "imagePushedAt": "2022-06-01T12:17:39-05:00",
               "imageManifestMediaType": "application/vnd.oci.image.manifest.v1+json"
           }
       ]
   }
   ```

# Pulling an image from the Amazon ECR Public Gallery
<a name="docker-pull-ecr-image"></a>

If you would like to run a Docker image that is available in Amazon ECR Public, you can pull it to your local environment with the **docker pull** command. You can do this from any public repository. Every public repository created on Amazon ECR Public is available on the Amazon ECR Public Gallery. Visit the Amazon ECR Public Gallery at [https://gallery.ecr.aws](https://gallery.ecr.aws). For more information, see [Amazon ECR Public Gallery](public-gallery.md).

Amazon ECR Public supports both unauthenticated and authenticated pulls from public repositories. There are separate service quotas for each type of image pull. For more information, see [Amazon ECR Public service quotas](public-service-quotas.md).
+ An unauthenticated pull is a pull without an auth token. You can confirm whether there is an auth token in your Docker configuration by checking your `~/.docker/config.json` file. If you've previously authenticated to Amazon ECR Public but you want to perform an unauthenticated pull, you can logout using the `docker logout public.ecr.aws` command which will remove the auth token from your Docker configuration file.
+ An authenticated pull requires that you authenticate to Amazon ECR Public prior to the pull request. For more information, see [Registry authentication in Amazon ECR public](public-registry-auth.md).

**Note**  
For authenticated pulls, Amazon ECR Public requires that users have permission to make calls to the `ecr-public:GetAuthorizationToken` and `sts:GetServiceBearerToken` API through an IAM policy before they can authenticate to Amazon ECR Public and pull an image from a public repository.

**To pull a public image from the Amazon ECR Public Gallery**

1. Identify the image to pull. You can view the available public repositories on the Amazon ECR Public Gallery at [https://gallery.ecr.aws](https://gallery.ecr.aws).

1. For authenticated pulls, you must authenticate your Docker client to the Amazon ECR public registry. Authentication tokens are valid for 12 hours. For more information, see [Registry authentication in Amazon ECR public](public-registry-auth.md).
**Note**  
For unauthenticated pulls, you can skip this step.

1. Pull the image using the **docker pull** command. The image name format should be `registry_alias/repository[:tag]` to pull by tag, or `registry_alias/repository[@digest]` to pull by digest.

   ```
   docker pull public.ecr.aws/registry_alias/repository:tag
   ```

# Deleting an image in a public repository in Amazon ECR public
<a name="public-image-delete"></a>

If you are done using an image, you can delete it from your public repository. You can delete an image using the AWS Management Console, or the AWS CLI.

**Note**  
If you are done with a public repository, you can delete the entire repository and all of the images within it. For more information, see [Deleting a public repository policy statement Amazon ECR public](public-repository-delete.md).

**To delete a public image with the AWS Management Console**

1. Open the Amazon ECR console at [https://console.aws.amazon.com/ecr/repositories](https://console.aws.amazon.com/ecr/repositories).

1. From the navigation bar, choose the Region that contains the image to delete.

1. In the navigation pane, choose **Repositories**.

1. On the **Repositories** page, select the **Public** tab and then select the repository containing the image to delete.

1. On the **Repositories: *repository\$1name*** page, select the box to the left of the image to delete and choose **Delete**.

1. In the **Delete image(s)** dialog box, verify that the selected images should be deleted and choose **Delete**.

**To delete a public image with the AWS CLI**

1. List the image tags in your repository.

   ```
   aws ecr-public describe-image-tags \
         --repository-name my-repo \
         --region us-east-1
   ```

1. (Optional) Delete any unwanted tags for the image by specifying the tag of the image you want to delete.
**Note**  
When you delete the last tag for an image, the image is deleted.

   ```
   aws ecr-public batch-delete-image \
         --repository-name my-repo \
         --image-ids imageTag=latest \
         --region us-east-1
   ```

1. Delete the image by specifying the digest of the image to delete.
**Note**  
When you delete an image by referencing its digest, the image and all of its tags are deleted.

   ```
   aws ecr-public batch-delete-image \
         --repository-name my-repo \
         --image-ids imageDigest=sha256:4f70ef7a4d29e8c0c302b13e25962d8f7a0bd304c7c2c1a9d6fa3e9de6bf552d
         --region us-east-1
   ```

# Container image manifest formats in Amazon ECR public
<a name="image-manifest-formats"></a>

Amazon ECR Public supports the following container image manifest formats:
+ Docker Image Manifest V2 Schema 1 (used with Docker version 1.9 and older)
+ Docker Image Manifest V2 Schema 2 (used with Docker version 1.10 and newer)
+ Open Container Initiative (OCI) Specifications (v1.0 and up)

Support for Docker Image Manifest V2 Schema 2 provides the following functionality:
+ The ability to use multiple tags per image.
+ Support for storing Windows container images. For more information, see [Pushing Windows Images to Amazon ECR](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-container-image.html#create-container-image-push-ecr) in the *Amazon Elastic Container Service Developer Guide*.

## Amazon ECR image manifest conversion
<a name="image-manifest-conversion"></a>

When you push and pull images to and from Amazon ECR Public, your container engine client (for example, Docker) communicates with the public registry to agree on a manifest format that is understood by the client and the registry to use for the image. 

When you push an image to Amazon ECR Public with Docker version 1.9 or older, the image manifest format is stored as Docker Image Manifest V2 Schema 1. When you push an image to Amazon ECR Public with Docker version 1.10 or newer, the image manifest format is stored as Docker Image Manifest V2 Schema 2.

When you pull an image from Amazon ECR Public *by tag*, Amazon ECR Public returns the image manifest format that is stored in the repository. The format is returned only if that format is understood by the client. If the stored image manifest format is not understood by the client, Amazon ECR Public converts the image manifest into a format that is understood by the client. For example, if a Docker 1.9 client requests an image manifest that is stored as Docker Image Manifest V2 Schema 2, Amazon ECR Public returns the manifest in the Docker Image Manifest V2 Schema 1 format. The table below describes the available conversions supported by Amazon ECR Public when an image is pulled *by tag*: 


| Schema requested by client | Pushed to ECR as V2, schema 1 | Pushed to ECR as V2, schema 2 | Pushed to ECR as OCI | 
| --- | --- | --- | --- | 
| V2, schema 1 | No translation required | Translated to V2, schema 1 | Translated to V2, schema 1 | 
| V2, schema 2 | No translation available, client falls back to V2, schema 1 | No translation required | Translated to V2, schema 2 | 
| OCI | No translation available | Translated to OCI | No translation required | 

**Important**  
If you pull an image *by digest*, there is no translation available; your client must understand the image manifest format that is stored in Amazon ECR. If you request a Docker Image Manifest V2 Schema 2 image by digest on a Docker 1.9 or older client, the image pull fails. For more information, see [Registry compatibility](https://docs.docker.com/registry/compatibility/) in the Docker documentation.  
In this example, if you request the same image *by tag*, Amazon ECR Public translates the image manifest into a format that the client can understand. The image pull succeeds.