Use cross-account instance synchronization to synchronize images from an instance in one Alibaba Cloud account to another. This region-independent feature supports both manual and automatic synchronization.
Usage notes
-
The source instance must be an Enterprise Edition instance. The destination instance can be an Basic or Advanced Edition instance.
To upgrade an Enterprise Edition instance, go to the Container Registry (ACR) console and click Upgrade in the lower-right corner of the instance card.
-
Synchronization from public cloud regions to non-public cloud regions such as Finance Cloud and Gov Cloud is not supported.
-
In some regions, special restrictions, such as no public network access for Object Storage Service (OSS) buckets, mean that only custom sync links are supported.
Background information
Cross-account instance synchronization supports synchronizing images between any combination of Alibaba Cloud accounts and RAM users.
Automatically synchronize instances across accounts
Configure a sync rule to automatically synchronize an image to a destination instance in another account when the image is pushed to the source instance. This topic assumes that the source instance belongs to Account A and the destination instance belongs to Account B.
Automatic cross-account instance synchronization applies only to images pushed after the sync rule is created; it does not synchronize existing images.
To synchronize existing images, use one of the following methods:
-
If you have a small number of existing images, synchronize them manually. For more information, see Manually synchronize instances across accounts and CreateRepoSyncTask.
-
For a large number of existing images, use the OSS replication + ACR image import solution:
-
Copy all files from the OSS bucket of the source instance to the OSS bucket of the destination ACR instance. For more information, see Data replication.
-
Create an import rule, select OSS Bucket as the migration source, and start an image import task.
-
Before you begin
Before you begin, obtain the following information:
-
The UIDs of Account A and Account B.
NoteIf you use a RAM user, obtain the UID of the Alibaba Cloud account to which the RAM user belongs.
-
The region and ID of the destination instance.
Log on to the ACR console. In the top navigation bar, select a region. On the Instances page, click the target Enterprise Edition instance. On the Overview page, view the Region of the instance. In the Instance section, find the Instance ID.
-
Automatic cross-account instance synchronization can be performed by namespace or by repository:
-
Synchronization by namespace requires a matching namespace name on both the source and destination instances. Automatic repository creation must also be enabled for the namespace in the destination instance. For more information about how to enable automatic repository creation, see Create a namespace.
-
Synchronization by repository requires a matching namespace and image repository name on both the source and destination instances.
-
Step 1: Grant permissions in Account B
In Account B, grant Account A permissions to synchronize images to the destination instance.
-
Create the aliyuncontainerregistrycrossaccoutsyncrole role.
NoteThe role name must be exactly
aliyuncontainerregistrycrossaccoutsyncrole. This exact name, including the typo, is required.-
Log on to the RAM console with Account B.
-
In the navigation pane on the left, choose . On the page that appears, click Create Role.
-
On the Create Role page, set Principal Type to Cloud Account, specify the details of the Alibaba Cloud account, and then click OK.
-
In the Create Role dialog box, enter
aliyuncontainerregistrycrossaccoutsyncroleas the role name and click Confirm.
-
-
Create an access policy.
-
In the navigation pane on the left of the RAM console, choose and click Create Policy.
-
On the Create Policy page, select JSON Editor. Replace the
Resourcefield in the following content as needed, copy the content into the text box, and then click Confirm. Then, in the Create Policy dialog box, enter a Policy Name and Description.NoteResource: The authorized resource. The format isacs:cr:<region_of_destination_instance_in_Account_B>:<UID_of_Account_B>:instance/<ID_of_destination_instance_in_Account_B>.If Account B is a RAM user, the
UID_of_Account_Bin theResourceparameter is the UID of the Alibaba Cloud account to which the RAM user belongs.{ "Statement": [ { "Effect": "Allow", "Action": [ "cr:CreateSyncRule", "cr:CreateRepositorySync", "cr:UpdateSyncRule" ], "Resource": "acs:cr:cn-beijing:151356101970****:instance/cri-4im1o411ls8g****" }, { "Effect": "Allow", "Action": [ "cr:CreateSyncRule", "cr:CreateRepositorySync", "cr:UpdateSyncRule" ], "Resource": "acs:cr:cn-hangzhou:151356101970****:instance/cri-4im1o411ls8gxr****" } ], "Version": "1" }
-
-
Attach the access policy that you created to the aliyuncontainerregistrycrossaccoutsyncrole role.
-
On the Policies page, search for and click the name of the access policy that you created.
-
Click the References tab and then click Attach Policy.
-
In the Add Permission panel, set Resource Scope to Account, set Principal to Principal, and then click OK.
-
Click Off.
-
-
Modify the trust policy of the aliyuncontainerregistrycrossaccoutsyncrole role.
-
In the navigation pane on the left of the RAM console, choose .
-
On the Roles page, search for and click
aliyuncontainerregistrycrossaccoutsyncrole. -
Click the Trust Policy tab and then click Edit Trust Policy.
-
In the editor, replace the value of the
Servicefield in the following policy with your information, and then click Save trust policy document.NoteService: The authorized principal. The format is<UID_of_Account_A>@cr.aliyuncs.com.If Account A is a RAM user, the
UID_of_Account_Ain theServiceparameter is the UID of the Alibaba Cloud account to which the RAM user belongs.{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "125287961064****@cr.aliyuncs.com" ] } } ], "Version": "1" }
-
Step 2: Create a sync rule in Account A
-
Log on to the ACR console with Account A.
In the top navigation bar, select a region.
In the left-side navigation pane, click Instances.
On the Instances page, click the Enterprise Edition instance that you want to manage.
-
In the navigation pane on the left, choose . On the page that appears, click Create Rule.
-
In the Create Rule dialog box, complete the Instance step, and click Next.
Parameter
Description
Rule Name
Enter a name for the sync rule.
Sync Scenario
Set Replication Scenario to Across Accounts.
Destination UID
Enter the UID of the Alibaba Cloud account to which the destination instance belongs.
Destination instance
Select the region of the destination instance and enter its instance ID.
-
In the Replication Information step, set Replication Level to either namespace or repository, select the corresponding namespace or repository, set a filtering rule for repository versions, and then click Create Rule.
On the instance management page, choose . On the Replication Record page, if the sync task status is Completed and the image appears in the destination instance, the synchronization was successful.
Manually synchronize instances across accounts
You can manually push an image from a source instance to a destination instance in another account. This topic assumes that the source instance is in Account A and the destination instance is in Account B.
-
Obtain the UIDs of Account A and Account B, and the region and ID of the destination instance. For more information, see the Before you begin section.
-
Grant Account A permissions to synchronize images to the instance in Account B. For details, see Step 1.
Log on to the Container Registry console.
In the top navigation bar, select a region.
In the left-side navigation pane, click Instances.
On the Instances page, click the Enterprise Edition instance that you want to manage.
In the left-side navigation pane of the management page of the Enterprise Edition instance, choose .
-
On the Repositories page, click the name of the target image repository.
-
In the navigation pane on the left of the repository details page, click Image Version. Find the target image version and click Replication in the Actions column.
-
In the Sync dialog box, set Replication Scenario to Across Accounts, enter the following details for the destination: account UID, region, instance ID, namespace, repository name, and image version. Then, click Confirm.
On the instance management page, choose . On the Replication Record page, if the sync task status is Completed and the image appears in the destination instance, the manual synchronization was successful.
Related topics
To synchronize an image to other regions within the same account, see intra-account instance synchronization. This method does not require account authorization.