I’m going to put tiny Docker tips here.

Here is the first one. Use docker images to get the information you actually want. Reverse sorted by size so you can clean it up.

docker images | sort --human-numeric-sort -k 7

Here is some truncated sample output

<juser1@laptop1:~>(home laptop)
zsh/2 69315 % docker images | sort --human-numeric-sort -k 7
REPOSITORY                                                  TAG                  IMAGE ID       CREATED         SIZE
busybox                                                     latest               e02e811dd08f   4 years ago     1.09MB
quay.io/prometheus/busybox                                  latest               747e1d7f6665   3 years ago     2.59MB
alpine                                                      3.6                  76da55c8019d   3 years ago     3.97MB
alpine                                                      3.5                  4a415e366388   3 years ago     3.99MB
alpine                                                      3.7                  e21c333399e0   3 years ago     4.14MB
alpine                                                      edge                 5c4fa780951b   2 years ago     4.15MB
alpine                                                      <none>               3fd9065eaf02   2 years ago     4.15MB
alpine                                                      3.8                  11cd0b38bc3c   2 years ago     4.41MB
byrnedo/alpine-curl                                         latest               549652d9246e   3 years ago     5.35MB
...
<none>                                                      <none>               8027707d7b33   18 hours ago    840MB
justinhop/brave                                             2020-12-06           b89c27bfdb18   3 weeks ago     846MB
justinhop/brave                                             latest               b89c27bfdb18   3 weeks ago     846MB
justinhop/synfig                                            2020-12-07           b3f261d67bcb   3 weeks ago     846MB
justinhop/synfig                                            latest               b3f261d67bcb   3 weeks ago     846MB

Clean up unnamed and hanging docker processes and images. You should really use the --rm flag to docker run

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

docker rmi $(docker images -q -f dangling=true)

I run the commands above through cron daily, to keep my file systems from filling up.

Categories: Systems