AWS ECR Repository - How to copy images from one account and push to another account
Jul 10
I have two accounts - Account A and Account B. In account A, I have a policy with a user from account B can interact with Account A. I have a repository in both accounts. Account B doesn't have a policy set ( Not sure if I need a policy for Account A to interact with it).
My question is how do I push ecr images from Account A into Account B. I would like a copy of Account A image into Account B. Is this possible.
1 answer
Accepted answer · original discussion
Jul 10
This is not a currently supported feature of ECR so you would need to perform the following steps to migrate from one account to another:
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com- Run this for the source accountdocker pull $SOURCE_IMAGE:$VERSION- Pull the latest tag down to your localdocker tag $SOURCE_IMAGE:$VERSION $TARGET_IMAGE:$VERSION- Tag a new image based on the original source imageaws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com- Run this for the target accountdocker push $TARGET_IMAGE:$VERSION- Push the docker image upto the target ECR account.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.