Configuring private image replication - Amazon ECR
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Configuring private image replication

The replication settings for your private registry are configured separately for each Region. Use the following steps to configure replication for your private registry using either the Amazon Web Services Management Console or the Amazon CLI. For examples of how replication is commonly used, see Private image replication examples.

  1. Open the Amazon ECR console at https://console.amazonaws.cn/ecr/repositories.

  2. From the navigation bar, choose the Region to configure your registry replication settings for.

  3. In the navigation pane, choose Private registry.

  4. On the Private registry page, on the Replication section, choose Edit.

  5. On the Replication page, choose Add replication rule.

  6. On the Destination types page, choose whether to enable cross-Region replication, cross-account replication, or both and then choose Next.

  7. If cross-Region replication is enabled, then for Configure destination regions, choose one or more Destination regions and then choose Next.

  8. If cross-account replication is enabled, then for Cross-account replication, choose the cross-account replication setting for the registry. For Destination account, enter the account ID for the destination account and one or more Destination regions to replicate to. Choose Destination account + to configure additional accounts as replication destinations.

    Important

    For cross-account replication to occur, the destination account must configure a registry permissions policy to allow replication to occur. For more information, see Private registry permissions.

  9. (Optional) On the Add filters page, specify one or more filters for the replication rule and then choose Add. Repeat this step for each filter you want to associate with the replication action. A filter must be specified as a repository name prefix. If no filters are added, the contents of all repositories are replicated. Choose Next once all filters have been added.

  10. On the Review and submit page, review the replication rule configuration and then choose Submit rule.

  1. Create a JSON file containing the replication rules to define for your registry. A replication configuration may contain up to 10 rules, with up to 25 unique destinations across all rules and 100 filters per each rule. To configure cross-Region replication within your own account, you specify your own account ID. For more examples, see Private image replication examples.

    { "rules": [{ "destinations": [{ "region": "destination_region", "registryId": "destination_accountId" }], "repositoryFilters": [{ "filter": "repository_prefix_name", "filterType": "PREFIX_MATCH" }] }] }
  2. Create a replication configuration for your registry.

    aws ecr put-replication-configuration \ --replication-configuration file://replication-settings.json \ --region us-west-2
  3. Confirm your registry settings.

    aws ecr describe-registry \ --region us-west-2

Private image replication examples

The following examples show common use cases for private image replication.

Example: Configuring cross-Region replication to a single destination Region

The following shows an example for configuring cross-Region replication within a single registry. This example assumes that your account ID is 111122223333 and that you're specifying this replication configuration in a Region other than us-west-2.

{ "rules": [ { "destinations": [ { "region": "us-west-2", "registryId": "111122223333" } ] } ] }

Example: Configuring cross-Region replication using a repository filter

The following shows an example for configuring cross-Region replication for repositories that match a prefix name value. This example assumes your account ID is 111122223333 and that you're specifying this replication configuration in a Region other than us-west-1 and have repositories with a prefix of prod.

{ "rules": [{ "destinations": [{ "region": "us-west-1", "registryId": "111122223333" }], "repositoryFilters": [{ "filter": "prod", "filterType": "PREFIX_MATCH" }] }] }

Example: Configuring cross-Region replication to multiple destination Regions

The following shows an example for configuring cross-Region replication within a single registry. This example assumes your account ID is 111122223333 and that you're specifying this replication configuration in a Region other than us-west-1 or us-west-2.

{ "rules": [ { "destinations": [ { "region": "us-west-1", "registryId": "111122223333" }, { "region": "us-west-2", "registryId": "111122223333" } ] } ] }

Example: Configuring cross-account replication

The following shows an example for configuring cross-account replication for your registry. This example configures replication to the 444455556666 account and to the us-west-2 Region.

Important

For cross-account replication to occur, the destination account must configure a registry permissions policy to allow replication to occur. For more information, see Private registry permissions.

{ "rules": [ { "destinations": [ { "region": "us-west-2", "registryId": "444455556666" } ] } ] }

Example: Specifying multiple rules in a configuration

The following shows an example for configuring multiple replication rules for your registry. This example configures replication for the 111122223333 account with one rule that replicates repositories with a prefix of prod to the us-west-2 Region and repositories with a prefix of test to the us-east-2 Region. A replication configuration may contain up to 10 rules, with each rule specifying up to 25 destinations.

{ "rules": [{ "destinations": [{ "region": "us-west-2", "registryId": "111122223333" }], "repositoryFilters": [{ "filter": "prod", "filterType": "PREFIX_MATCH" }] }, { "destinations": [{ "region": "us-east-2", "registryId": "111122223333" }], "repositoryFilters": [{ "filter": "test", "filterType": "PREFIX_MATCH" }] } ] }