Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of apt autoremove in Python Alpine image

I am trying to purge unused dependency to reduce image size.

This was addressed in Ubuntu images by

sudo-apt autoremove

Please help me with the command to be used in Alpine.

like image 236
kanurag94 Avatar asked Mar 26 '26 20:03

kanurag94


2 Answers

No, no equivalent in apk for alpine.

But, you really do not need it, because apk del will delete the unused dependency for you when you delete a package, it's totally different with apt. See this:

Remove a Package
Use del to remove a package (and dependencies that are no longer needed.)

Also you can have a try (vim for example):

/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
v3.10.1-40-g92381611d0 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.1-37-g530a544685 [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
OK: 10335 distinct packages available

/ # apk add vim
(1/5) Installing lua5.3-libs (5.3.5-r2)
(2/5) Installing ncurses-terminfo-base (6.1_p20190518-r0)
(3/5) Installing ncurses-terminfo (6.1_p20190518-r0)
(4/5) Installing ncurses-libs (6.1_p20190518-r0)
(5/5) Installing vim (8.1.1365-r0)

/ # apk del vim
(1/5) Purging vim (8.1.1365-r0)
(2/5) Purging lua5.3-libs (5.3.5-r2)
(3/5) Purging ncurses-libs (6.1_p20190518-r0)
(4/5) Purging ncurses-terminfo (6.1_p20190518-r0)
(5/5) Purging ncurses-terminfo-base (6.1_p20190518-r0)
Executing busybox-1.30.1-r2.trigger
OK: 6 MiB in 14 packages

You can see in above, all package dependency when install vim will be purged when delete the package.

like image 113
atline Avatar answered Mar 29 '26 09:03

atline


For alpine: apk del package-name, (apk is the package management utility for alipine) more information here: https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management.

Also I suggest when creating your image (assuming you are starting FROM alpine), to use RUN apk add --no-cache <package> which allows you to not cache the index locally.

Here you can search for the packages which are available for alpine: https://pkgs.alpinelinux.org/packages

like image 25
dejanualex Avatar answered Mar 29 '26 09:03

dejanualex