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:
docker image rm -f $(docker images -a | grep -v "put_image_id_here" | awk 'NR>1 {print $3}')
Example:
docker image rm -f $(docker images -a | grep -v "c8562eaf9d81" | awk 'NR>1 {print $3}')
To get docker image ID we can run command:
# list all images
docker images
# list all images (with dangling images)
docker images -a