docker:remove_an_image
This is an old revision of the document!
Table of Contents
Docker - Remove an image
Find the image
docker images
Returns
REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 16.10 df4ba6fcd70e 36 hours ago 100.2 MB ubuntu 16.04 f753707788c5 36 hours ago 127.2 MB ubuntu latest f753707788c5 36 hours ago 127.2 MB hello-world latest c54a2cc56cbb 3 months ago 1.848 kB docker/whalesay latest 6b362a9f73eb 16 months ago 247 MB
docker rmi image_name
Seeing all created containers is as simple as docker ps -a.
To remove all existing containers (not images!) run docker rm $(docker ps -aq)
Removing images according to a pattern
You can find all the images that match a pattern using a combination of docker images and grep. Once you're satisfied, you can delete them by using awk to pass the IDs to docker rmi. Note that these utilities are not supplied by Docker and are not necessarily available on all systems:
To find the images:
docker ps -a | grep "pattern"
To remove the images:
docker images | grep "pattern" | awk '{print $1}' | xargs docker rm
docker/remove_an_image.1487775947.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)