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
<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:
Post a Comment