EN
Docker remove all images except one
3 points
In this article we whould like to show how to delete all docker images except one.
Quick solution:
xxxxxxxxxx
1
docker image rm -f $(docker images -a | grep -v "put_image_id_here" | awk 'NR>1 {print $3}')
Example:
xxxxxxxxxx
1
docker image rm -f $(docker images -a | grep -v "c8562eaf9d81" | awk 'NR>1 {print $3}')
To get docker image ID we can run command:
xxxxxxxxxx
1
# list all images
2
docker images
3
4
# list all images (with dangling images)
5
docker images -a