Guides / Linux servers

Security updates on Alpine Linux servers: apk upgrade on a schedule

beginnerUpdated 26 Nov 2026589 words

Alpine Linux does not have an automatic update tool like unattended-upgrades or dnf-automatic. On a server you run apk upgrade from the crond of BusyBox once a day, and before a branch ends you move the server to the next one by hand.

For a container image based on Alpine, rebuild the image on a current tag instead of upgrading inside the running container: see keeping Docker images updated.

See what is pending

apk update
apk version -l '<'

apk version -l '<' lists the installed packages that have a newer version in the repositories. apk upgrade --simulate shows what an upgrade would change, without changing it:

apk upgrade --simulate

apk does not have a security-only mode. apk upgrade installs every update of the branch you are on.

Upgrade on a schedule

The crontab of root runs the scripts in /etc/periodic/daily at 02:00:

0	2	*	*	*	run-parts /etc/periodic/daily

Put the upgrade there:

cat > /etc/periodic/daily/apk-upgrade <<'EOF'
#!/bin/sh
# Daily package upgrade from the Alpine repositories of this release.
apk update --quiet && apk upgrade --quiet 2>&1 | logger -t apk-upgrade
EOF
chmod 755 /etc/periodic/daily/apk-upgrade

crond is off on some minimal installations. Turn it on:

rc-update add crond default
rc-service crond start

Give the script a name without a dot (apk-upgrade, not apk-upgrade.sh). The BusyBox run-parts of Alpine 3.24 runs both, but the run-parts of Debian skips names with a dot, and a copy of the script there would never run.

Run the job once by hand and look for its lines in the system log:

run-parts /etc/periodic/daily
grep apk-upgrade /var/log/messages

run-parts --test /etc/periodic/daily lists the scripts that would run, without running them.

After a kernel upgrade

Alpine keeps one kernel version installed. After an upgrade of linux-lts or linux-virt, the modules of the running kernel are gone from /lib/modules, and loading a module (for a new firewall rule or a Docker network, for example) can fail until the next boot. Compare:

uname -r
ls /lib/modules

When they differ, plan a reboot (when to reboot after updates).

Move to a new branch

Each stable branch gets fixes in the main repository for about two years, and in the community repository until the next stable branch is out (dates in the end-of-life guide). The daily job stays on the branch named in /etc/apk/repositories. To move to the next one:

cat /etc/alpine-release
sed -i 's|/v3\.23/|/v3.24/|g' /etc/apk/repositories
apk update
apk upgrade --available
sync
reboot

--available sets every package to the version in the configured repositories, even where that version is lower. Read the release notes of the new branch first: they list removed packages and changed defaults.

You can skip branches. In a test, a container on 3.20 went to 3.24 in one step; apk upgraded itself from apk-tools 2 to apk-tools 3 first and then the other packages.

Check the result

cat /etc/alpine-release
apk version -l '<'     # only the header line when everything is current
uname -r               # after the reboot, matches /lib/modules

Vulnpocalypse matches the installed packages of each server with the Alpine security database once a day. A CVE with a fix that is not installed yet shows up with the apk upgrade line for it.

Sources

Check your servers every day

The Vulnpocalypse agent reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.

Start free