Skip to content

Latest commit

 

History

History
205 lines (138 loc) · 3.52 KB

File metadata and controls

205 lines (138 loc) · 3.52 KB

Alpine

https://wiki.alpinelinux.org

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.

Package Management

https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management

Repositories

/etc/apk/repositories

Get the latest package lists:

apk update

Search

Search packages for anything with the word "$name" in it:

apk search "$name"

Show all packages:

apk search

Show all packages and versions:

apk search -v

Install / Uninstall Packages

Install 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 clean

Info

List packages:

apk info

Show versions:

apk -v info

Show versions + descriptions:

apk -vv info

Find which package installed a given file on disk:

apk info --who-owns /bin/sh

Show package contents:

apk info -L <pkg>

Show all info on package:

apk info -a "$pkg"

Upgrades

Upgrade system, all packages:

apk upgrade

Upgrade specific package:

apk add --upgrade "$pkg"

Testing Alpine Upgrades

Run an older version, eg. 3.18:

docker run --rm -it alpine:3.18 sh

Download the package lists and ensure the alpine-keys are installed:

apk update &&
apk add --no-cache alpine-keys

Update the repository to point to a newer version:

sed -i 's/v3\.18/v3\.21/g' /etc/apk/repositories

Update the package lists to the newer version:

apk update

Now 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.

apk-file

:octocat: genuinetools/apk-file

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+