Tuesday 14 July 2020

Pruning Docker - And there's more ....

Now I've written about this before, in the context of cleaning down Docker environments, but I found a useful tip today, to help remove old/unwanted Docker images from a box.

These are images that are effectively unnamed / untagged, as per this example: -

docker images

<none>                                                           <none>                         4a492ff5f010        11 days ago         2.66GB

My Ubuntu build server had LOADS of these.

Put it this way, the command: -

df -kmh /var

returned this: -

/dev/mapper/basevg-var  433G  318G   94G  78% /var

most of which was taken up by /var/lib/docker

These unbranded images are known as "Dangling Images" and can be queried thusly: -

docker images -f "dangling=true" 

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              4a492ff5f010        11 days ago         2.66GB


and pruned accordingly: -

docker rmi `docker images -f "dangling=true" -q`

As mentioned before, I also use this command: -

docker rm `docker ps -a|grep Exited|awk '{print $1}'`

to remove stopped containers.


No comments:

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...