Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove tag from image

I have an image (in AWS ECR) with 2 tags and I would like to remove one tag only.

I can easily remove from my local environment using: docker rmi <REPOSITORY>:<TAG>

I would like to remove it from ECR. Any help would be appreciated.

like image 277
Squirrel Avatar asked May 24 '19 20:05

Squirrel


People also ask

How do I remove a tag from a photo in Photoshop?

Here are the steps: Select the picture in question. Open the Tags pane and you should see the offending tag. Hover over the tag, and you'll see an 'X' at the right, clicking on that X will remove the tag from that picture.

How do you remove a tag?

Android & iOS App Find the post you wish to remove the tag from, then select the arrow next to it. Tap “Report/Remove Tag“. Select the reason. I usually just go with “I'm in this photo and I don't like it”.

Can I Retag myself in a post?

Your only option for undoing the effects of removing a tag is to reapply that tag. When you're the owner of the photo you're retagging, the tag is applied immediately. If you retag a photo you didn't upload, the person whose photo you're reapplying the tag to may have to approve the tag before it's applied.

Can you remove a tag from an Instagram photo?

Tap the photo or video. Tap your username. Tap Remove Me From Post.


2 Answers

You can delete a tag using command:

aws ecr batch-delete-image --repository-name <REPO NAME> --image-ids imageTag=<TAG NAME>

I you have only one tag and execute this command then it will remove the image. If you have multiple tags for the same image, specify one and only the tag is removed.

like image 190
Squirrel Avatar answered Sep 24 '22 07:09

Squirrel


In case one needs to delete more tags, here is a an extension of the accepted answer:

ECR_REPO="my-repo-name"

# Create a file with the list of AWS ECR tags, with one tag per line
aws ecr list-images --repository-name $ECR_REPO --filter "tagStatus=TAGGED" \
    --query "imageIds[*]" --output text \
    | cut -f2 > ecr-image-tags-${ECR_REPO}.txt

# For each tag, delete the image on AWS ECR
cat ecr-image-tags-${ECR_REPO}.txt | xargs -I {} \
    aws ecr batch-delete-image --repository-name ${ECR_REPO} --image-ids imageTag={} | cat

You can also replace cat by grep -E PATTERN in the last line if you want to selectively delete tagged images with a specific pattern.

like image 39
Pierre Avatar answered Sep 22 '22 07:09

Pierre