I have docker image with several tags. I want to remove this docker image with all its tags. If I do that manually I want to list the tags and delete one by one.
I have found some way to delete the images and all its tags with single command. It combine various commands with linux pipe
Following are the break down of all commands that I have used
1. docker images
List all docker images. I have quite a lot of docker images. :)
grep the images that contain the name
3. tr -s
tr utility copies the given input to produced the output with substitution or deletion of selected characters. In here I’m removing
spaces of previous command output.
4. cut -d
cut command allows to extract the specific part from a text. In here I’m extracting the
5. xargs -I
xargs command allows to convert input of standard input into argument of another command. In above command it returns a list of tags, I can
echo the full name of the image with the tag by using
To delete the image with all its tags, I can
xargs the docker tag inputs to
docker rmi command.