Menu Close

Remove untagged images from docker

by jimhoskins.com

In the process of running docker I accumulated several images that are not tagged. To remove these I use this command:

docker rmi $(docker images -a | grep "^" | awk '{print $3}')

This works by using rmi with a list of image ids. To get the image ids we call docker images then pipe it to grep “^”. The grep will filter it down to only lines with the value “” in the repository column. Then to extract the id out of the third column we pipe it to awk “{print $3}” which will print the third column of each line passed to it.

After running these two commands I recovered 15G of space. There may be more I could do to recover more space, my docker graph directory still is over 5G, but for now this works.

 

Sometimes, docker doesn’t remove volumes associated to deleted containers.

For delete all orphaned volumes you can use this command:

docker volume rm $(docker volume ls -qf dangling=true)
Posted in Domotica e Cloud, Linux, News

Leave a Reply

Your email address will not be published. Required fields are marked *