Minimal Linux distribution used mainly to create small Docker images.
Uses busybox all-in-one binary with minimal core shell and coreutils functionality.
Replaced libc with musl core library which sometimes causes problems with progam compiling or grep buggy behaviour.
https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management
/etc/apk/repositories
Get the latest package lists:
apk updateSearch packages for anything with the word "$name" in it:
apk search "$name"Show all packages:
apk searchShow all packages and versions:
apk search -vInstall a given package:
apk add "$pkg"On Alpine 3+ you can skip the prerequisite apk update by adding the -u switch to add:
apk add -u "$pkg"Uninstall package:
apk del "$pkg"Delete the local package list cache:
(usually done at the end of a Dockerfile RUN to not save it to the docker image)
apk cache cleanList packages:
apk infoShow versions:
apk -v infoShow versions + descriptions:
apk -vv infoFind which package installed a given file on disk:
apk info --who-owns /bin/shShow package contents:
apk info -L <pkg>Show all info on package:
apk info -a "$pkg"Upgrade system, all packages:
apk upgradeUpgrade specific package:
apk add --upgrade "$pkg"Run an older version, eg. 3.18:
docker run --rm -it alpine:3.18 shDownload the package lists and ensure the alpine-keys are installed:
apk update &&
apk add --no-cache alpine-keysUpdate the repository to point to a newer version:
sed -i 's/v3\.18/v3\.21/g' /etc/apk/repositoriesUpdate the package lists to the newer version:
apk updateNow you should see several outdated packages to test with:
apk version -l '<'Installed: Available:
alpine-baselayout-3.4.3-r1 < 3.6.8-r1
alpine-baselayout-data-3.4.3-r1 < 3.6.8-r1
alpine-keys-2.4-r1 < 2.5-r0
apk-tools-2.14.4-r0 < 2.14.6-r3
busybox-1.36.1-r7 < 1.37.0-r14
busybox-binsh-1.36.1-r7 < 1.37.0-r14
ca-certificates-bundle-20241121-r1 < 20250911-r0
libcrypto3-3.1.8-r0 < 3.3.6-r0
libssl3-3.1.8-r0 < 3.3.6-r0
musl-1.2.4-r3 < 1.2.5-r9
musl-utils-1.2.4-r3 < 1.2.5-r9
scanelf-1.3.7-r1 < 1.3.8-r1
ssl_client-1.36.1-r7 < 1.37.0-r14
zlib-1.2.13-r1 < 1.3.1-r2
Now test whatever upgrades you want.
apt-file but for Alpine, finds
Go binary that searches which packages contain a given filename.
docker run --rm -ti jess/apk-file <file>Ported from private Knowledge Base page 2015+