Languages
[Edit]
EN

Docker remove all images except one

3 points
Created by:
Root-ssh
84940

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

 

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join