I have a private Docker repository on AWS ECR.
I'm trying to tag an existing image with a new tag using the instructions here https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-retag.html
For example, say I have an image with tag "1.5.0", and now I want to add the tag "lts", by using the method above to "batch-get-image" of tag "1.5.0", and then "put-image" with "image-tag" "lts", the command creates a brand new image in the repository with the tag "lts". The original image "1.5.0" is unaffected.
Code:
MANIFEST=$(aws ecr batch-get-image --region eu-west-1 --repository-name mynamespace/repo --image-ids imageTag='1.5.0' --query 'images[].imageManifest' --output text)
aws ecr put-image --region eu-west-1 --repository-name mynamespace/repo --image-tag lts --image-manifest "$MANIFEST"
The above results in two separate images:
- lts
- 1.5.0
I want 1 image:
- 1.5.0, lts
Any ideas what I'm doing wrong? The repository setting has immutability disabled.
I would rather avoid the docker pull
, docker tag
, docker push
approach as this will run on my CI server (Github Actions) in a separate workflow where docker pull
would be a very wasteful command.