0

I was trying to remove all dangling images including the images which have <none> as repo name or tag while listing with docker images command.

enter image description here

Now, if you try to remove the images , you may have seen that the docker rmi <image_id> commands might fail due to presence of invalid docker containers which were Exited abruptly and persisted as below.

enter image description here

It is tedious to remove all the containers and dependent images one by. Hence, is there a good way of removing such images quickly or in automated way ?

Dhrubo
  • 705
  • 1
  • 14
  • 33

1 Answers1

1

Easier way to remove such images and dependent containers to use following commands sequentially...

docker ps -a | grep "Exited " | awk '{print $1}' | xargs docker rm
docker images -f dangling=true | grep "none" | awk '{print $3}'| xargs docker rmi

you can also use docker image prune to remove all dangling images first.

Above commands will remove all dangling and <none> images from your system. You can also use docker image prune -a to remove ALL UNUSED images, but use it with CAUTIONs.

Dhrubo
  • 705
  • 1
  • 14
  • 33