How to upgrade Alpine Linux 3.4/3.5 to 3.6.xx

Posted on in Categories , , last updated May 26, 2017

I am using Alpine Linux v3.4 or v3.5 with my LXD server. How do I upgrade Alpine Linux v3.4 to Alpine Linux v3.5? How can I upgrade Alpine Linux v3.5 to Alpine Linux v3.6?

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. 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.
Fig.01: Upgrading an Alpine Linux Hard-disk installation
Fig.01: Upgrading an Alpine Linux Hard-disk installation

Find out your Alpine Linux version

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

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
Save and close the file. Next grabt the latest index:
# apk update
Sample outputs:

fetch http://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.0-3-g6bc3261f0a [http://dl-3.alpinelinux.org/alpine//v3.6/main]
v3.6.0_rc3-20-g62a475001d [http://dl-3.alpinelinux.org/alpine/v3.6/community]
OK: 8479 distinct packages available

To upgrade all your packages, run apk command:
# apk upgrade --available
OR
# apk upgrade --purge
Sample outputs:

Upgrading critical system libraries and apk-tools:
(1/3) Installing libressl2.5-libcrypto (2.5.4-r0)
(2/3) Installing libressl2.5-libssl (2.5.4-r0)
(3/3) Upgrading apk-tools (2.6.8-r2 -> 2.7.1-r1)
Executing busybox-1.25.1-r0.trigger
Continuing the upgrade transaction with new apk-tools:
(1/50) Upgrading musl (1.1.15-r6 -> 1.1.16-r9)
(2/50) Upgrading busybox (1.25.1-r0 -> 1.26.2-r4)
Executing busybox-1.26.2-r4.post-upgrade
(3/50) Replacing alpine-baselayout (3.0.4-r0 -> 3.0.4-r0)
Executing alpine-baselayout-3.0.4-r0.pre-upgrade
Executing alpine-baselayout-3.0.4-r0.post-upgrade
(4/50) Upgrading openrc (0.21.7-r4 -> 0.24.1-r2)
Executing openrc-0.24.1-r2.post-upgrade
(5/50) Upgrading alpine-conf (3.5.0-r2 -> 3.6.0_rc2-r0)
(6/50) Upgrading zlib (1.2.8-r2 -> 1.2.11-r0)
(7/50) Upgrading busybox-suid (1.25.1-r0 -> 1.26.2-r4)
(8/50) Upgrading busybox-initscripts (3.0-r8 -> 3.1-r1)
Executing busybox-initscripts-3.1-r1.post-upgrade
(9/50) Upgrading scanelf (1.1.6-r0 -> 1.2.2-r0)
(10/50) Upgrading musl-utils (1.1.15-r6 -> 1.1.16-r9)
(11/50) Upgrading libc-utils (0.7-r1 -> 0.7.1-r0)
(12/50) Upgrading alpine-keys (1.3-r0 -> 2.1-r1)
(13/50) Upgrading alpine-base (3.5.2-r0 -> 3.6.0-r0)
(14/50) Replacing ncurses-terminfo-base (6.0-r7 -> 6.0-r7)
(15/50) Replacing ncurses-terminfo (6.0-r7 -> 6.0-r7)
(16/50) Replacing ncurses-libs (6.0-r7 -> 6.0-r7)
(17/50) Upgrading readline (6.3.008-r4 -> 6.3.008-r5)
(18/50) Upgrading bash (4.3.46-r5 -> 4.3.48-r1)
Executing bash-4.3.48-r1.post-upgrade
(19/50) Replacing bash-completion (2.4-r0 -> 2.4-r0)
(20/50) Upgrading bash-doc (4.3.46-r5 -> 4.3.48-r1)
(21/50) Replacing popt (1.16-r6 -> 1.16-r6)
(22/50) Upgrading logrotate (3.10.0-r0 -> 3.12.2-r0)
(23/50) Upgrading mariadb-common (10.1.22-r0 -> 10.1.22-r1)
(24/50) Upgrading mariadb-client (10.1.22-r0 -> 10.1.22-r1)
(25/50) Upgrading mysql-client (10.1.22-r0 -> 10.1.22-r1)
(26/50) Upgrading pcre (8.39-r0 -> 8.40-r2)
(27/50) Upgrading nginx (1.10.3-r0 -> 1.12.0-r2)
Executing nginx-1.12.0-r2.post-upgrade
(28/50) Upgrading php5-common (5.6.30-r0 -> 5.6.30-r2)
(29/50) Upgrading libxml2 (2.9.4-r2 -> 2.9.4-r3)
(30/50) Upgrading php5-cli (5.6.30-r0 -> 5.6.30-r2)
(31/50) Upgrading php5 (5.6.30-r0 -> 5.6.30-r2)
Executing php5-5.6.30-r2.post-upgrade
(32/50) Upgrading ca-certificates (20161130-r1 -> 20161130-r2)
(33/50) Upgrading libssh2 (1.7.0-r2 -> 1.8.0-r1)
(34/50) Upgrading libcurl (7.52.1-r3 -> 7.54.0-r0)
(35/50) Upgrading php5-curl (5.6.30-r0 -> 5.6.30-r2)
(36/50) Upgrading php5-fpm (5.6.30-r0 -> 5.6.30-r2)
(37/50) Replacing libbz2 (1.0.6-r5 -> 1.0.6-r5)
(38/50) Upgrading libpng (1.6.25-r0 -> 1.6.29-r1)
(39/50) Upgrading freetype (2.7-r1 -> 2.7.1-r1)
(40/50) Replacing libjpeg-turbo (1.5.1-r0 -> 1.5.1-r0)
(41/50) Upgrading php5-gd (5.6.30-r0 -> 5.6.30-r2)
(42/50) Upgrading libintl (0.19.8.1-r0 -> 0.19.8.1-r1)
(43/50) Upgrading php5-gettext (5.6.30-r0 -> 5.6.30-r2)
(44/50) Upgrading php5-mysql (5.6.30-r0 -> 5.6.30-r2)
(45/50) Upgrading php5-mysqli (5.6.30-r0 -> 5.6.30-r2)
(46/50) Upgrading php5-opcache (5.6.30-r0 -> 5.6.30-r2)
(47/50) Upgrading php5-zlib (5.6.30-r0 -> 5.6.30-r2)
(48/50) Upgrading tzdata (2016i-r0 -> 2017a-r0)
(49/50) Purging libressl2.4-libssl (2.4.4-r0)
(50/50) Purging libressl2.4-libcrypto (2.4.4-r0)
Executing busybox-1.26.2-r4.trigger
Executing ca-certificates-20161130-r2.trigger
OK: 90 MiB in 51 packages

Restart the server/VM container:
# sync
# reboot

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

For more information see https://alpinelinux.org/.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment


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

Comments are closed.