`apk del` now downloads packages cache
The behavior of
apk del has changed so it now automatically downloads packages cache and so the pattern used in many Dockerfiles (
apk add --no-cache gcc && ... && apk del gcc) now causes unnecessary packages cache to be included in the final image: https://github.com/frol/docker-alpine-glibc/issues/22
Should I update all my Dockerfiles to use
apk del --no-cache instead of
main/apk-tools: don't update index on delete
backport from upstream
(cherry picked from commit 09b110fc99a36f12c0b49e6029a231a231ce920d)
#1 Updated by Vlad Frolov 7 months ago
It also affects Alpine 3.7 as
apk 2.9.1 is shipped to it as well.
Consider the following script:
apk add --no-cache bash apk del bash
apk 2.8.2 works fine and there is nothing left in the
/ # ls -la /var/cache/apk/ total 1092 drwxr-xr-x 1 root root 4096 Jul 8 08:23 . drwxr-xr-x 1 root root 4096 Apr 10 18:27 ..
apk 2.9.1 works fine as well, but there are APKINDEX files left in the
/var/cache/apk/ folder now:
/ # ls -la /var/cache/apk/ total 1208 drwxr-xr-x 1 root root 4096 Jul 8 08:46 . drwxr-xr-x 1 root root 4096 Jul 5 14:46 .. -rw-r--r-- 1 root root 451471 Jul 8 08:46 APKINDEX.5022a8a2.tar.gz -rw-r--r-- 1 root root 768769 Jul 8 08:46 APKINDEX.70c88391.tar.gz
Thus, some Docker images may become 1.2MB bigger now.