mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.58k stars 1.15k forks source link

Enhanced docker image cleanup, "<none>" Tag #3293

Closed christianbur closed 4 years ago

christianbur commented 4 years ago

Is your feature request related to a problem? Please describe. if images are updated where REPOSITORY and TAG are equal, the old image is renamed to REPOSITORY:<none>. These <none> images are not cleaned by the update function in the update.sh script.

root@server# docker images |grep 'mailcow\|nginx\|mariadb\|memcached\|redis\|ipv6nat'
mailcow/netfilter         1.31                e9e5f2f3bba7        24 hours ago        79.8MB
mailcow/rspamd            1.59                5cba53d42984        24 hours ago        159MB
mailcow/acme              1.64                c5acb89d6054        24 hours ago        113MB
mailcow/phpfpm            1.55                5766c88fd6ee        24 hours ago        336MB
mailcow/olefy             1.2                 4e3e3ad1c7ff        24 hours ago        87.2MB
mailcow/solr              1.7                 d018ecac0587        24 hours ago        620MB
mailcow/dockerapi         1.36                3826158d1f66        24 hours ago        74.9MB
mailcow/postfix           1.44                eef369495020        24 hours ago        269MB
mailcow/sogo              1.70                0099a80367e0        24 hours ago        478MB
mailcow/dovecot           1.108               ccc84ea9e67c        24 hours ago        397MB
mailcow/unbound           1.10                ca46f4db3135        24 hours ago        20.9MB
mailcow/clamd             1.35                620392be1014        24 hours ago        214MB
nginx                     mainline-alpine     48c8a7c47625        39 hours ago        21.8MB
memcached                 alpine              db5a019f09c8        40 hours ago        9.09MB
mailcow/sogo              <none>              63f74bc43045        3 days ago          478MB
redis                     5-alpine            b68707e68547        7 days ago          29.8MB
mailcow/acme              <none>              e54800828a5b        7 days ago          117MB
mariadb                   10.3                1632679210bd        9 days ago          343MB
mariadb                   10.4                bc20d5f8d0fe        9 days ago          355MB
mailcow/rspamd            <none>              b7c165384522        13 days ago         159MB
mailcow/dovecot           <none>              dec8e7f18607        2 weeks ago         402MB
mailcow/watchdog          1.67                76adb2d8768b        3 weeks ago         103MB
mailcow/dockerapi         <none>              037253cd4815        4 weeks ago         74.3MB
mailcow/netfilter         <none>              2dcc9faf2749        4 weeks ago         82.4MB
mailcow/phpfpm            <none>              766f3ca7155c        4 weeks ago         339MB
mailcow/solr              <none>              df537896e541        4 weeks ago         620MB
mailcow/postfix           <none>              5a97b4f937a4        4 weeks ago         269MB
mailcow/unbound           <none>              421ae97b1278        4 weeks ago         20.8MB
mailcow/clamd             <none>              d4b6c6f2c344        4 weeks ago         214MB
mailcow/olefy             <none>              961926f178c1        4 weeks ago         89.7MB
robbertkl/ipv6nat         latest              f46f4d37caac        7 weeks ago         21.5MB

Describe the solution you'd like With the following command you could delete this <none> images. If the <none> images are still used from another container, the command will not delete them.

docker images |grep 'mailcow\|nginx\|mariadb\|memcached\|redis\|ipv6nat' |grep "<none>" |awk '{printf "%s\n",$3}' |xargs -I {} sh -c "docker rmi {}"

Additional context The command must be added in this section.

andryyy commented 4 years ago

The prune command should take care of it.

You sometimes need to run it a few times, until all relations between images are found and solved.

You can check it by running docker system prune (or docker images prune) followed by ´docker images --filter "dangling=true"`.

christianbur commented 4 years ago

"docker system prune" is too dangerous for me, because if I am not careful, important things can be deleted.

andryyy commented 4 years ago

It does not delete volumes (anymore? It did a while ago).

christianbur commented 4 years ago

That's what I'm talking about, if this is fixed, fine. Then we close the ticket.

MAGICCC commented 4 years ago

It only deletes volumes when you append --volumes https://docs.docker.com/engine/reference/commandline/system_prune/#options