I'm looking for an equivalent to apt autoremove
I've seen stated everywhere online that it's not required because apk does it automatically when doing apk del
. But it's very easy to verify that it doesn't actually does that:
docker run --entrypoint "/bin/sh" -it python:3.9-alpine
# apk add gcc
.......
OK: 117 MiB in 46 packages
# apk del gcc
....
OK: 14 MiB in 36 packages
You can also run apk list
before and after to convince yourself of all the packages that were not removed
as you can see there are 113 MB worth of packages that were not removed (apk list shows hundreds of packages here), I really want to get rid of everything that was installed.
How can I do that ? Is that a bug, should everything be removed ? What can I do ?
I asked myself the same question, so to verify I did some tests:
What you get is that:
apk add
says it downloads 200MiB (arbitrary value for the example), it might actually only install an additional 160MiB.apk del
says it uninstalled 20MiB (arbitrary value for the example), it does indeed remove the other 160MiB, which mean that apk del
is indeed doing its work properly.The reason why the image is suddenly growing in size is because docker is doing some caching steps in-between. If possible, try to do the install and uninstall in a single RUN
command.