Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting all Docker images from a repository

Tags:

docker

I want to delete all Ubuntu images from Docker. Here is what docker images shows:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
nginx               test                b585568733c7        3 weeks ago         93.46 MB
ubuntu              14.04               ce76de2e871b        4 weeks ago         188 MB
ubuntu              12.04               583364cb662d        4 weeks ago         138 MB
tommylau/ocserv     latest              26d1014b5930        5 weeks ago         145.6 MB
nginx               1.7.11              520f1dbba9d6        12 months ago       93.44 MB

How can I delete ubuntu:14.04 and ubuntu:12.04 with a single command?

like image 902
shalbafzadeh Avatar asked Mar 27 '16 14:03

shalbafzadeh


People also ask

How do I remove docker image referenced in multiple repositories?

You cannot remove images having multiple repositories without the force modifier, see Docker docs for more info. If you use the -f flag and specify the image's short or long ID, then rmi untags and removes all images that match the specified ID.

How do I remove a docker image from a repository?

To remove the image, you first need to list all the images to get the Image IDs, Image name and other details. By running simple command docker images -a or docker images . After that you make sure which image want to remove, to do that executing this simple command docker rmi <your-image-id> .


1 Answers

You can use

docker rmi $(docker images -q ubuntu)

-q lists only the image id, and docker images -q ubuntu lists all ubuntu images' ids.

like image 132
Xiongbing Jin Avatar answered Oct 22 '22 02:10

Xiongbing Jin