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.
Make a backup of your LXD container
Type the following command to create container snapshots:
$ lxc snapshot alpine-www01 "JUNE272018"
$ lxc info alpine-www01
Name: alpine-www01 Remote: unix:// Architecture: x86_64 Created: 2017/07/17 11:38 UTC Status: Running Type: persistent Profiles: default Pid: 2652 Ips: eth0: inet 10.105.28.45 veth0H03I3 eth0: inet6 fe80::216:3eff:fe1c:8793 veth0H03I3 lo: inet 127.0.0.1 lo: inet6 ::1 Resources: Processes: 38 CPU usage: CPU usage (in seconds): 88 Memory usage: Memory (current): 65.80MB Memory (peak): 80.70MB Network usage: eth0: Bytes received: 5.97MB Bytes sent: 3.23MB Packets received: 51890 Packets sent: 30849 lo: Bytes received: 246.80kB Bytes sent: 246.80kB Packets received: 1840 Packets sent: 1840 Snapshots: Dec052017 (taken at 2017/12/05 07:33 UTC) (stateless) JUNE272018 (taken at 2018/06/26 22:54 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
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:
To update to 3.5.xx, enter:
Change the version number by hand. For example, the default entry for 3.5 is as follows:
To update to 3.5.xx, enter:
Change the version number by hand. For example, the default entry for 3.6 is as follows:
Make sure you change the version number by hand. For example, the default entry for 3.7 is as follows:
To update to 3.8.xx, enter:
Save and close the file. Next grab the latest index using apk command:
# apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz v3.8.0-4-gc5ede23c7e [http://dl-cdn.alpinelinux.org/alpine/v3.8/main] v3.8.0-4-gc5ede23c7e [http://dl-cdn.alpinelinux.org/alpine/v3.8/community] OK: 9599 distinct packages available
To upgrade all your packages, run apk command:
# apk upgrade --available
# apk upgrade --purge
Upgrading critical system libraries and apk-tools: (1/3) Installing libressl2.7-libcrypto (2.7.4-r0) (2/3) Installing libressl2.7-libssl (2.7.4-r0) (3/3) Upgrading apk-tools (2.9.1-r2 -> 2.10.0-r0) Executing busybox-1.27.2-r11.trigger Executing ca-certificates-20171114-r0.trigger Continuing the upgrade transaction with new apk-tools: (1/41) Upgrading musl (1.1.18-r3 -> 1.1.19-r10) (2/41) Upgrading busybox (1.27.2-r11 -> 1.28.4-r0) Executing busybox-1.28.4-r0.post-upgrade (3/41) Upgrading alpine-baselayout (3.0.5-r2 -> 3.1.0-r0) Executing alpine-baselayout-3.1.0-r0.pre-upgrade Executing alpine-baselayout-3.1.0-r0.post-upgrade (4/41) Upgrading openrc (0.24.1-r4 -> 0.35.5-r4) Executing openrc-0.35.5-r4.post-upgrade (5/41) Upgrading alpine-conf (3.7.0-r1 -> 3.8.0-r0) (6/41) Installing libressl2.7-libtls (2.7.4-r0) (7/41) Upgrading ssl_client (1.27.2-r11 -> 1.28.4-r0) (8/41) Upgrading busybox-suid (1.27.2-r11 -> 1.28.4-r0) (9/41) Upgrading busybox-initscripts (3.1-r2 -> 3.1-r3) Executing busybox-initscripts-3.1-r3.post-upgrade (10/41) Upgrading scanelf (1.2.2-r1 -> 1.2.3-r0) (11/41) Upgrading musl-utils (1.1.18-r3 -> 1.1.19-r10) (12/41) Upgrading alpine-base (3.7.0-r0 -> 3.8.0-r0) (13/41) Upgrading pkgconf (1.3.10-r0 -> 1.5.1-r0) (14/41) Upgrading ncurses-terminfo-base (6.0_p20171125-r0 -> 6.1-r0) (15/41) Upgrading ncurses-terminfo (6.0_p20171125-r0 -> 6.1-r0) (16/41) Upgrading ncurses-libs (6.0_p20171125-r0 -> 6.1-r0) (17/41) Upgrading bash-completion (2.7-r3 -> 2.8-r0) (18/41) Upgrading ca-certificates (20171114-r0 -> 20171114-r3) (19/41) Upgrading libssh2 (1.8.0-r2 -> 1.8.0-r3) (20/41) Upgrading pcre2 (10.30-r0 -> 10.31-r0) (21/41) Upgrading git (2.15.2-r0 -> 2.18.0-r0) (22/41) Upgrading git-bash-completion (2.15.2-r0 -> 2.18.0-r0) (23/41) Upgrading libressl (2.6.5-r0 -> 2.7.4-r0) (24/41) Upgrading logrotate (3.13.0-r0 -> 3.14.0-r0) (25/41) Upgrading mariadb-common (10.1.32-r0 -> 10.2.15-r0) (26/41) Installing libgcc (6.4.0-r8) (27/41) Installing libstdc++ (6.4.0-r8) (28/41) Upgrading mariadb-client (10.1.32-r0 -> 10.2.15-r0) (29/41) Upgrading mysql-client (10.1.32-r0 -> 10.2.15-r0) (30/41) Upgrading libbsd (0.8.6-r1 -> 0.8.6-r2) (31/41) Upgrading pcre (8.41-r1 -> 8.42-r0) (32/41) Upgrading nginx (1.12.2-r3 -> 1.14.0-r0) Executing nginx-1.14.0-r0.pre-upgrade Executing nginx-1.14.0-r0.post-upgrade (33/41) Replacing php5 (5.6.36-r0 -> 5.6.36-r0) Executing php5-5.6.36-r0.post-upgrade (34/41) Replacing php5-common (5.6.36-r0 -> 5.6.36-r0) (35/41) Upgrading libxml2 (2.9.7-r0 -> 2.9.8-r0) (36/41) Upgrading freetype (2.8.1-r3 -> 2.9.1-r1) (37/41) Upgrading libjpeg-turbo (1.5.2-r0 -> 1.5.3-r1) (38/41) Upgrading libintl (0.19.8.1-r1 -> 0.19.8.1-r2) (39/41) Upgrading libwebp (0.6.0-r1 -> 1.0.0-r0) (40/41) Upgrading vnstat (1.17-r0 -> 1.18-r0) (41/41) Purging libressl2.6-libtls (2.6.5-r0) Executing busybox-1.28.4-r0.trigger Executing ca-certificates-20171114-r3.trigger OK: 107 MiB in 71 packages
Restart the server/VM container:
$ cat /etc/alpine-release
Conclusion – Upgrade Alpine Linux
And there you have it, Alpine Linux upgraded from version 3.7 to 3.8. For more information see https://alpinelinux.org/.