non-slim Debian image does not clean up apt
jaskij opened this issue · 2 comments
I just noticed that the non-slim image of Debian does not contain these two lines at the end, is this intentional?
apt-get remove -y --auto-remove \
wget \
; \
rm -rf /var/lib/apt/lists/*;
I was not around when this was originally added, but I believe this is added to the slim images to reduce their size as much as possible. As for why non-slim doesn't have it, I think it is because they are typically used as images to be built upon, and you want to keep apt
's lists around. I checked node
's slim template and it also had rm -rf /var/lib/apt/lists/*
while their Debian template did not.
On the other hand Docker's own buildpack-deps
does do the removal. It is also a standard practice for Debian-based images to run apt-get update
before installing anything, which regenerates the cache.
I did a quick check - on a Bookworm system, the size of /var/lib/apt/lists/*
is 82 MB, while regenerating the cache on my machine took under three seconds. This is with a 30 Mbps internet connection, running on a Ryzen 5 3600 with an NVMe.
On the other hand - this risks breaking images which do not run apt-get update
.
Personally, I don't see why everyone cares about image sizes, since Docker has great deduplication, and wanted to just check in if this was intended since it seemed unusual.
If you do care about image size, I would suggest making this a breaking change to be deployed with Trixie (Debian 13, with ETA April 2025).