Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy docker image from one AWS ECR repo to another

We want to copy a docker image from non-prod to prod ECR account. Is it possible without pulling, retaging and pushing it again.

like image 963
letthefireflieslive Avatar asked Nov 16 '18 07:11

letthefireflieslive


People also ask

How do I copy a Docker image from one repo to another?

In order to transfer a Docker image from one server to another, what you need to do is first export the image to a file, then copy that file over from your current server to the new one using scp or rsync and finally load the image to your new server.

How do I move a Docker image to AWS ECR?

Identify the local image to push. Run the docker images command to list the container images on your system. You can identify an image with the repository:tag value or the image ID in the resulting command output. Tag your image with the Amazon ECR registry, repository, and optional image tag name combination to use.

How do you replicate ECR to another region?

To get started you simply enable replication, choose the destination accounts and regions you want ECR to copy images to. After this, every time you push an image to the private repository, ECR automatically replicates the image.


3 Answers

No you have to run these commands

docker login OLD_REPO
docker pull OLD_REPO/IMAGE:TAG
docker tag OLD_REPO/IMAGE:TAG NEW_REPO/IMAGE:TAG
docker login NEW_REPO
docker push NEW_REPO/IMAGE:TAG
like image 133
Banjo Obayomi Avatar answered Oct 03 '22 21:10

Banjo Obayomi


I have written this program in python to migrate all the images (or a specific image) from a repository to another region or to another account in a different region https://gist.github.com/fabidick22/6a1962697357360f0d73e01950ae962b

like image 40
fabidick22 Avatar answered Oct 03 '22 21:10

fabidick22


Answer: No, you must pull, tag, and push.

I wrote a bash script for this today. You can specify the number of tagged images that will be copied.

https://gist.github.com/virtualbeck/a635ef6701991f2087384eab7edbb18b

like image 20
Mike Beck Avatar answered Oct 03 '22 20:10

Mike Beck