This episode takes a deep dive into apk, Alpine's package manager. You'll learn the basic apk update, add, del, and upgrade commands, the repository structure in /etc/apk/repositories, and apk search, info, and audit. The episode also explains the differences between apk v2 on older versions and apk v3 on Alpine 3.23 and later.

Packages are how Alpine distributes software, and apk (Alpine Package Keeper) is the vehicle. Episode 4 covers apk thoroughly: basic commands, repository structure, querying and auditing, up to the differences between apk v2 and apk v3 introduced in Alpine 3.23.
Since apk is the tool you'll use in almost every episode, mastering it early will make the whole series much smoother. The goal isn't just to memorize commands, but to understand apk's working model so you can predict its behavior in new situations.
The four most frequently used commands:
apk update
apk add nginx
apk add --no-cache curl
apk del nginx
apk upgradeBrief explanation:
apk update refreshes the package index from the repositories.apk add installs a package together with its dependencies.apk add --no-cache installs without keeping the index — required in Dockerfiles.apk del removes a package.apk upgrade upgrades all packages to the latest versions in the active repositories.Installing packages with dependencies is handled automatically by apk's SAT solver, so you don't need to worry about choosing an order:
apk add vim git htopOne detail that sets apk apart from apt: after apk del nginx, packages that are no longer needed aren't automatically removed. Use apk fix when there are problematic dependencies:
apk fixThe /etc/apk/repositories file determines the active repositories, one line per repository:
https://dl-cdn.alpinelinux.org/alpine/v3.24/main
https://dl-cdn.alpinelinux.org/alpine/v3.24/communityTo add the testing repository, append its line:
echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
apk updateDon't forget to adjust the version number to match your release. Mixing different versions in a single repositories file can cause conflicts, so always use a single branch.
To find and inspect packages, apk provides query commands:
apk search nginx
apk search -d "web server" | head -10
apk info -e nginx
apk info -a nginx | head -20
apk info -W /usr/bin/nginxExplanation:
apk search finds packages by name or description.apk info -e checks whether a package is installed.apk info -a shows a package's full metadata.apk info -W finds the owner of a file.apk audit compares the filesystem against the package database to detect changed or missing files:
apk audit
apk audit --systemThe apk audit output shows files that were added or changed from their post-install state. In episode 13, this command becomes one of the security hardening tools for detecting suspiciously modified files.
Alpine 3.23 (December 2025) introduced apk v3, a major release with a new archive and index format. The differences you need to know:
Check the running apk version:
apk --version
apk versionThe apk --version output shows a number like apk-tools 3.0.0-r1 on Alpine 3.24, or apk-tools 2.14.x on releases before 3.23. The everyday command syntax hasn't changed, so your knowledge stays valid across versions.
Info
Never mix packages from different branches, for example v3.24 with edge, on a single system. apk will resolve them technically, but this combination isn't supported and often breaks upgrades.
Episode 4 covered apk from the basic commands to the repository architecture: update, add, del, and upgrade for the package lifecycle; main, community, and testing as repository tiers; search, info, and audit for querying; and the differences between apk v2 and apk v3.
Key takeaways:
In the next episode, episode 5, we'll discuss OpenRC: init system and service management — how Alpine boots without systemd, managing services with rc-service and rc-update, reading rc-status, and writing init scripts and configuration in /etc/conf.d.