I am trying to retag and copy an image from a repository to another within the same repository, without the use of Docker but only with the aws cli
I first get the manifest for the image i want to copy (step 1), i get this without any exception, but when i try to put
it to the new repository (step 2), aws tells me the layers are not there, i find it strange because if i get the layers from the manifest in step 1 it means that they are there, those are the commands i am running:
Step 1:
MANIFEST=$(aws ecr batch-get-image --repository-name REPO_NAME --image-ids imageTag=THE_CURRENT_IMMAGE_TAG --profile MY_PROFILE --output json | jq --raw-output '.images[].imageManifest')
Step 2:
aws ecr put-image --repository-name NEW_REPOSITORY_NAME --image-tag NEW_IMAGE_TAG --image-manifest "$MANIFEST" --profile MY_PROFILE
This returns:
An error occurred (LayersNotFoundException) when calling the PutImage operation: Layers with digests '[sha256....]'required for pushing image into repository with name 'NEW_REPOSITORY_NAME ' in the registry with id 'MY_REGISTRY' do not exist
I cant figure out what am i doing wrong here, unfortunately i cant find any examples online similar to mine, any idea?
I encountered a similar problem myself. It seems that the ECR PutImage operation doesn't facilitate the direct transfer of images between repositories. This limitation likely stems from the underlying architecture used by ECR for storing image layers.
From my understanding, when you invoke the PutImage command, it doesn't perform a complete copy of all image layers. Instead, it assumes that the necessary layers are already available within the repository. As a result, attempting to transfer images between repositories using this command may not yield the desired outcome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With