Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all tags for a docker repository locally?

Tags:

bash

docker

I want to remove all tags on a given docker repository locally. For example, if I had two tags on a repo called "my_image:latest" and "my_image:sometag" I would want to remove both of those tags. However, I do not want to remove "another_image:latest".

like image 968
Tim Martin Avatar asked Jan 07 '23 17:01

Tim Martin


1 Answers

To list the images you want to remove:

$ docker images --filter='reference=my_image' --format='{{.Repository}}:{{.Tag}}'

To delete them as well, combine with docker rmi:

$ docker images --filter='reference=my_image' --format='{{.Repository}}:{{.Tag}}' | xargs docker rmi
like image 99
aude Avatar answered Jan 16 '23 03:01

aude