How to upgrade Alpine Linux 3.12 to 3.13

I am using Alpine Linux v3.11 or v3.12 with my LXD server. How do I upgrade Alpine Linux v3.11 to Alpine Linux v3.13? How can I upgrade Alpine Linux v3.12 to Alpine Linux v3.13?

Before you type any one of the following command make sure that you have a backup of your important data before continuing to update your system. It is important that you keep full backup of your system. Alpine Linux is built around musl libc and busybox. This makes it smaller and more resource efficient than traditional GNU/Linux distributions. A container requires no more than 8 MB and a minimal installation to disk requires around 130 MB of storage. Not only do you get a fully-fledged Linux environment but a large selection of packages from the repository. It is perfect for Docker too.

Fig.01: Upgrading an Alpine Linux Hard-disk installation

Alpine Linux was designed with security in mind. The kernel is patched with an unofficial port of grsecurity/PaX, and all userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection. These proactive security features prevent exploitation of entire classes of zero-day and other vulnerabilities. When Alpine Linux is installed to hard drive or as LXD VM, upgrading to a newer stable version is straightforward.

How to upgrade Alpine Linux

When Alpine Linux is installed to hard drive or cloud server, upgrading to a newer stable version is easy:

  1. Edit /etc/apk/repositories file, run: vi /etc/apk/repositories
  2. Change the version number by hand. For example, Alpine 3.12 to 3.13
  3. Save and close the file
  4. Fetch latest index by running the apk update
  5. Upgrade all your Alpine Linux packages: apk upgrade --available && sync
  6. Reboot the system, run: reboot

Let us see all commands and examples in details.

Make a backup of your LXD container

Type the following command to create container snapshots:
$ lxc snapshot alpine-www01 "JAN162021"
Verify it:
$ lxc info alpine-www01
Sample outputs:

Name: alpine-www01
Remote: unix://
Architecture: x86_64
Created: 2019/01/04 06:25 UTC
Status: Running
Type: persistent
Profiles: default
Pid: 28917
Ips:
  lo:	inet	127.0.0.1
  lo:	inet6	::1
  eth0:	inet	10.105.28.45	vethJ4APTV
  eth0:	inet6	fe80::216:3eff:fee6:6afa	vethJ4APTV
Resources:
  Processes: 34
  CPU usage:
    CPU usage (in seconds): 3
  Memory usage:
    Memory (current): 201.15MB
    Memory (peak): 203.21MB
  Network usage:
    eth0:
      Bytes received: 87.31kB
      Bytes sent: 435.99kB
      Packets received: 384
      Packets sent: 333
    lo:
      Bytes received: 17.74kB
      Bytes sent: 17.74kB
      Packets received: 30
      Packets sent: 30
Snapshots:
  Feb-03-2019 (taken at 2019/02/02 18:38 UTC) (stateless)
  mar-04-2019 (taken at 2019/03/04 16:23 UTC) (stateless)
  may-04-2019 (taken at 2019/05/03 21:56 UTC) (stateless)
  June-21-2019 (taken at 2019/06/20 19:58 UTC) (stateless)
  June-24-2019 (taken at 2019/06/23 20:29 UTC) (stateless)
  DEC232019 (taken at 2019/12/23 18:20 UTC) (stateless)
  JUN052020 (taken at 2020/06/05 10:45 UTC) (stateless)
  JAN162021 (taken at 2021/01/16 06:13 UTC) (stateless)

Now login to your Alpine Linux box/LXD VM using ssh command or lxc command.

Find out your Alpine Linux version

Type the following command:
$ cat /etc/alpine-release
3.12.3

Apply all pending updates for 3.12.xx

Simply run the apk command:
# apk update
# apk upgrade

fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.3-63-g6bd01a05ab [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.3-62-gebf75fec7d [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]

How to upgrading to latest release

Edit /etc/apk/repositories file, enter:
# vi /etc/apk/repositories
Change the version number by hand. For example, the default entry for 3.4 is as follows:
http://dl-3.alpinelinux.org/alpine/v3.4/main
To update to 3.5.xx, enter:
http://dl-3.alpinelinux.org/alpine/v3.5/main
Change the version number by hand. For example, the default entry for 3.5 is as follows:
http://dl-3.alpinelinux.org/alpine/v3.5/main
To update to 3.5.xx, enter:
http://dl-3.alpinelinux.org/alpine/v3.6/main
For example, 3.12.xx it is as follows:
http://dl-cdn.alpinelinux.org/alpine/v3.12/main
So make it as follows for 3.12.xx upgrade, enter:
http://dl-cdn.alpinelinux.org/alpine/v3.13/main
Save and close the file. Here is my sample config file displayed using cat command:
# cat /etc/apk/repositories
Here is my updated file:

http://dl-cdn.alpinelinux.org/alpine/v3.13/main
http://dl-cdn.alpinelinux.org/alpine/v3.13/community

It is also possible to the last stable release on the repository file:

http://dl-3.alpinelinux.org/alpine/latest-stable/main
http://dl-3.alpinelinux.org/alpine/latest-stable/community

I avoid setting up the last stable release as I update my Alpine Linux fleet using Ansible. So I need to verify manually.

Upgrading alpine Linux

Next, grab the latest index using apk command:
# apk update
Sample outputs:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
v3.13.0-2-gc6c2cd54a0 [http://dl-cdn.alpinelinux.org/alpine/v3.13/main]
v3.13.0-5-g974ef030d3 [http://dl-cdn.alpinelinux.org/alpine/v3.13/community]
OK: 13931 distinct packages available

Try to detect upgrade problems by simulating the procedure to avoid downtime. Hence, pass the following options:
# apk upgrade --no-self-upgrade --available --simulate
Dry run output:

(1/66) Upgrading musl (1.1.24-r10 -> 1.2.2-r0)
(2/66) Upgrading busybox (1.31.1-r19 -> 1.32.1-r0)
(3/66) Upgrading alpine-baselayout (3.2.0-r7 -> 3.2.0-r8)
(4/66) Installing ifupdown-ng (0.10.2-r2)
(5/66) Upgrading openrc (0.42.1-r11 -> 0.42.1-r19)
(6/66) Upgrading alpine-conf (3.9.0-r1 -> 3.11.0-r2)
(7/66) Replacing libcrypto1.1 (1.1.1i-r0 -> 1.1.1i-r0)
(8/66) Replacing libssl1.1 (1.1.1i-r0 -> 1.1.1i-r0)
(9/66) Upgrading ca-certificates-bundle (20191127-r4 -> 20191127-r5)
(10/66) Replacing libtls-standalone (2.9.1-r1 -> 2.9.1-r1)
.....
.......
..

If no problems found or after solving them, start the proper upgrade procedure. Hence, type any one of the following command to upgrade all your packages, run apk command:
# apk upgrade --available
OR
# apk upgrade --purge
Look out for messages and warnings:

Upgrading critical system libraries and apk-tools:
(1/2) Upgrading musl (1.1.24-r10 -> 1.2.2-r0)
(2/2) Upgrading apk-tools (2.10.5-r1 -> 2.12.0-r4)
Executing busybox-1.31.1-r19.trigger
Continuing the upgrade transaction with new apk-tools:
(1/64) Upgrading busybox (1.31.1-r19 -> 1.32.1-r0)
Executing busybox-1.32.1-r0.post-upgrade
(2/64) Upgrading alpine-baselayout (3.2.0-r7 -> 3.2.0-r8)
Executing alpine-baselayout-3.2.0-r8.pre-upgrade
Executing alpine-baselayout-3.2.0-r8.post-upgrade
(3/64) Installing ifupdown-ng (0.10.2-r2)
(4/64) Upgrading openrc (0.42.1-r11 -> 0.42.1-r19)
Executing openrc-0.42.1-r19.post-upgrade
(5/64) Upgrading alpine-conf (3.9.0-r1 -> 3.11.0-r2)
(6/64) Replacing libcrypto1.1 (1.1.1i-r0 -> 1.1.1i-r0)
(7/64) Replacing libssl1.1 (1.1.1i-r0 -> 1.1.1i-r0)
(8/64) Upgrading ca-certificates-bundle (20191127-r4 -> 20191127-r5)
(9/64) Replacing libtls-standalone (2.9.1-r1 -> 2.9.1-r1)
(10/64) Upgrading ssl_client (1.31.1-r19 -> 1.32.1-r0)
(11/64) Replacing zlib (1.2.11-r3 -> 1.2.11-r3)
(12/64) Upgrading busybox-suid (1.31.1-r19 -> 1.32.1-r0)
(13/64) Replacing busybox-initscripts (3.2-r2 -> 3.2-r2)
Executing busybox-initscripts-3.2-r2.post-upgrade
(14/64) Upgrading scanelf (1.2.6-r0 -> 1.2.8-r0)
(15/64) Upgrading musl-utils (1.1.24-r10 -> 1.2.2-r0)
(16/64) Replacing libc-utils (0.7.2-r3 -> 0.7.2-r3)
(17/64) Replacing alpine-keys (2.2-r0 -> 2.2-r0)
(18/64) Upgrading alpine-base (3.12.3-r0 -> 3.13.0-r0)
(19/64) Upgrading ca-certificates (20191127-r4 -> 20191127-r5)
(20/64) Upgrading brotli-libs (1.0.9-r1 -> 1.0.9-r3)
(21/64) Upgrading nghttp2-libs (1.41.0-r0 -> 1.42.0-r1)
(22/64) Upgrading libcurl (7.69.1-r3 -> 7.74.0-r0)
(23/64) Upgrading curl (7.69.1-r3 -> 7.74.0-r0)
(24/64) Replacing pcre (8.44-r0 -> 8.44-r0)
(25/64) Upgrading nginx (1.18.0-r1 -> 1.18.0-r13)
Executing nginx-1.18.0-r13.post-upgrade
*
* The default and preferred location for nginx vhost configs has been changed
* from /etc/nginx/conf.d to /etc/nginx/http.d. Although we did our best to not
* break existing setups by this upgrade, we strongly recommend to verify it.
*
(26/64) Installing nginx-openrc (1.18.0-r13)
(27/64) Upgrading php7-common (7.3.26-r0 -> 7.4.14-r0)
(28/64) Replacing argon2-libs (20190702-r1 -> 20190702-r1)
(29/64) Upgrading ncurses-terminfo-base (6.2_p20200523-r0 -> 6.2_p20210109-r0)
(30/64) Upgrading ncurses-libs (6.2_p20200523-r0 -> 6.2_p20210109-r0)
(31/64) Upgrading libedit (20191231.3.1-r0 -> 20191231.3.1-r1)
(32/64) Upgrading pcre2 (10.35-r0 -> 10.36-r0)
(33/64) Replacing xz-libs (5.2.5-r0 -> 5.2.5-r0)
(34/64) Upgrading libxml2 (2.9.10-r5 -> 2.9.10-r6)
(35/64) Upgrading php7 (7.3.26-r0 -> 7.4.14-r0)
(36/64) Upgrading php7-curl (7.3.26-r0 -> 7.4.14-r0)
(37/64) Upgrading php7-fpm (7.3.26-r0 -> 7.4.14-r0)
(38/64) Replacing libxau (1.0.9-r0 -> 1.0.9-r0)
(39/64) Replacing libbsd (0.10.0-r0 -> 0.10.0-r0)
(40/64) Replacing libxdmcp (1.1.3-r0 -> 1.1.3-r0)
(41/64) Replacing libxcb (1.14-r1 -> 1.14-r1)
(42/64) Upgrading libx11 (1.6.12-r0 -> 1.7.0-r0)
(43/64) Replacing libxext (1.3.4-r0 -> 1.3.4-r0)
(44/64) Replacing libice (1.0.10-r0 -> 1.0.10-r0)
(45/64) Upgrading libuuid (2.35.2-r0 -> 2.36.1-r1)
(46/64) Replacing libsm (1.2.3-r0 -> 1.2.3-r0)
(47/64) Replacing libxt (1.2.0-r0 -> 1.2.0-r0)
(48/64) Replacing libxpm (3.5.13-r0 -> 3.5.13-r0)
(49/64) Replacing libbz2 (1.0.8-r1 -> 1.0.8-r1)
(50/64) Replacing libpng (1.6.37-r1 -> 1.6.37-r1)
(51/64) Upgrading freetype (2.10.4-r0 -> 2.10.4-r1)
(52/64) Upgrading libjpeg-turbo (2.0.5-r0 -> 2.0.6-r0)
(53/64) Replacing libwebp (1.1.0-r0 -> 1.1.0-r0)
(54/64) Upgrading php7-gd (7.3.26-r0 -> 7.4.14-r0)
(55/64) Upgrading libintl (0.20.2-r0 -> 0.20.2-r2)
(56/64) Upgrading php7-gettext (7.3.26-r0 -> 7.4.14-r0)
(57/64) Upgrading php7-json (7.3.26-r0 -> 7.4.14-r0)
(58/64) Upgrading php7-openssl (7.3.26-r0 -> 7.4.14-r0)
(59/64) Upgrading php7-mysqlnd (7.3.26-r0 -> 7.4.14-r0)
(60/64) Upgrading php7-mysqli (7.3.26-r0 -> 7.4.14-r0)
(61/64) Upgrading php7-opcache (7.3.26-r0 -> 7.4.14-r0)
(62/64) Upgrading php7-phar (7.3.26-r0 -> 7.4.14-r0)
(63/64) Upgrading php7-session (7.3.26-r0 -> 7.4.14-r0)
(64/64) Upgrading php7-simplexml (7.3.26-r0 -> 7.4.14-r0)
Executing busybox-1.32.1-r0.trigger
Executing ca-certificates-20191127-r5.triggerOK: 34 MiB in 66 packages

Restart the server/VM container:
# sync
# reboot

Verify it:
$ cat /etc/alpine-release
3.13.0

Please note that in some case /etc/alpine-release may not be updated, so query:
cat /etc/alpine-release.apk-new

Another alternative is to query /etc/issue:
# cat /etc/issue

Welcome to Alpine Linux 3.13
Kernel \r on an \m (\l)

Here is how it actually looks:

Welcome to Alpine Linux 3.13
Kernel 5.4.0-1035-aws on an x86_64 (/dev/console)

alpine-www01 login: 

Conclusion – Upgrade Alpine Linux

And there you have it, Alpine Linux upgraded from version 3.12 to 3.13. For more information see https://alpinelinux.org/.


🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Dimdo Feb 6, 2017 @ 15:29

    Why two slashes?

  • Legion Anonymous Feb 17, 2017 @ 3:33


    RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.5/main' | tee -a /etc/apk/repositories \
    && echo 'http://dl-cdn.alpinelinux.org/alpine/v3.5/community' | tee -a /etc/apk/repositories \
    && apk upgrade --purge

  • Jimmy Jan 20, 2021 @ 7:36

    Perfect. Just before running apk upgrade –available I do this
    # rm /etc/alpine-release
    So after reboot my server will have correct version.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz