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

in Categories , , last updated December 5, 2017

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

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

Make a backup of your LXD container

Type the following command to create container snapshots:
$ lxc snapshot alpine-www01 "snap0-Dec-05-2017-b4-update"
Verify it:
$ lxc info alpine-www01
Sample outputs:

Name: alpine-www01
Remote: unix://
Architecture: x86_64
Created: 2017/07/17 11:38 UTC
Status: Running
Type: persistent
Profiles: default
Pid: 2297
  eth0:	inet	vethELBFFO
  eth0:	inet6	fe80::216:3eff:fe1c:8793	vethELBFFO
  lo:	inet
  lo:	inet6	::1
  Processes: 33
  CPU usage:
    CPU usage (in seconds): 302
  Memory usage:
    Memory (current): 67.72MB
    Memory (peak): 86.41MB
  Network usage:
      Bytes received: 15.70MB
      Bytes sent: 10.35MB
      Packets received: 220397
      Packets sent: 123106
      Bytes received: 1.89MB
      Bytes sent: 1.89MB
      Packets received: 12806
      Packets sent: 12806
  snap0-Dec-05-2017-b4-update (taken at 2017/12/05 07:33 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:
To update to 3.7.xx, enter:
Save and close the file. Next grab the latest index using apk command:
# apk update
Sample outputs:

v3.7.0-8-g7f9d974993 []
v3.7.0-9-geec9573c5c []
OK: 9106 distinct packages available

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

Upgrading critical system libraries and apk-tools:
(1/3) Installing libressl2.6-libcrypto (2.6.3-r0)
(2/3) Installing libressl2.6-libssl (2.6.3-r0)
(3/3) Upgrading apk-tools (2.7.4-r0 -> 2.8.1-r1)
Executing busybox-1.26.2-r9.trigger
Executing ca-certificates-20161130-r2.trigger
Continuing the upgrade transaction with new apk-tools:
(1/64) Upgrading musl (1.1.16-r14 -> 1.1.18-r2)
(2/64) Upgrading busybox (1.26.2-r9 -> 1.27.2-r6)
NOTE: /usr/bin/telnet has been moved to the package 'busybox-extras'
NOTE: /usr/sbin/httpd has been moved to the package 'busybox-extras'
NOTE: /usr/bin/ftpget has been moved to the package 'busybox-extras'
NOTE: /usr/bin/ftpput has been moved to the package 'busybox-extras'
NOTE: /usr/sbin/ftpd has been moved to the package 'busybox-extras'
NOTE: /usr/bin/tftp has been moved to the package 'busybox-extras'
NOTE: /usr/sbin/fakeidentd has been moved to the package 'busybox-extras'
NOTE: /usr/sbin/dnsd has been moved to the package 'busybox-extras'
NOTE: /usr/sbin/inetd has been moved to the package 'busybox-extras'
NOTE: /usr/sbin/udhcpd has been moved to the package 'busybox-extras'
(3/64) Upgrading alpine-baselayout (3.0.4-r0 -> 3.0.5-r2)
Executing alpine-baselayout-3.0.5-r2.pre-upgrade
(4/64) Upgrading openrc (0.24.1-r2 -> 0.24.1-r4)
(5/64) Upgrading alpine-conf (3.6.0-r0 -> 3.7.0-r0)
(6/64) Upgrading zlib (1.2.11-r0 -> 1.2.11-r1)
(7/64) Upgrading busybox-suid (1.26.2-r9 -> 1.27.2-r6)
(8/64) Upgrading busybox-initscripts (3.1-r1 -> 3.1-r2)
(9/64) Upgrading scanelf (1.2.2-r0 -> 1.2.2-r1)
(10/64) Upgrading musl-utils (1.1.16-r14 -> 1.1.18-r2)
(11/64) Replacing libc-utils (0.7.1-r0 -> 0.7.1-r0)
(12/64) Replacing alpine-keys (2.1-r1 -> 2.1-r1)
(13/64) Upgrading alpine-base (3.6.2-r0 -> 3.7.0-r0)
(14/64) Installing pkgconf (1.3.10-r0)
(15/64) Replacing ncurses-terminfo-base (6.0_p20170930-r0 -> 6.0_p20170930-r0)
(16/64) Replacing ncurses-terminfo (6.0_p20170930-r0 -> 6.0_p20170930-r0)
(17/64) Replacing ncurses-libs (6.0_p20170930-r0 -> 6.0_p20170930-r0)
(18/64) Upgrading readline (6.3.008-r5 -> 7.0.003-r0)
(19/64) Upgrading bash (4.3.48-r1 -> 4.4.12-r1)
(20/64) Upgrading bash-completion (2.4-r0 -> 2.7-r3)
(21/64) Upgrading bc (1.06.95-r2 -> 1.07.1-r0)
(22/64) Upgrading ca-certificates (20161130-r2 -> 20171114-r0)
(23/64) Upgrading libssh2 (1.8.0-r1 -> 1.8.0-r2)
(24/64) Upgrading libcurl (7.56.1-r0 -> 7.57.0-r0)
(25/64) Upgrading curl (7.56.1-r0 -> 7.57.0-r0)
(26/64) Upgrading expat (2.2.0-r1 -> 2.2.5-r0)
(27/64) Installing pcre2 (10.30-r0)
(28/64) Upgrading git (2.13.5-r0 -> 2.15.0-r1)
(29/64) Upgrading git-bash-completion (2.13.5-r0 -> 2.15.0-r1)
(30/64) Installing libressl2.6-libtls (2.6.3-r0)
(31/64) Upgrading libressl (2.5.5-r0 -> 2.6.3-r0)
(32/64) Upgrading popt (1.16-r6 -> 1.16-r7)
(33/64) Upgrading logrotate (3.12.2-r0 -> 3.13.0-r0)
(34/64) Upgrading mariadb-common (10.1.26-r0 -> 10.1.28-r1)
(35/64) Upgrading mariadb-client (10.1.26-r0 -> 10.1.28-r1)
(36/64) Upgrading mysql-client (10.1.26-r0 -> 10.1.28-r1)
(37/64) Upgrading libbsd (0.8.3-r3 -> 0.8.6-r1)
(38/64) Replacing netcat-openbsd (1.130-r1 -> 1.130-r1)
(39/64) Upgrading pcre (8.41-r0 -> 8.41-r1)
(40/64) Upgrading nginx (1.12.2-r1 -> 1.12.2-r3)
Executing nginx-1.12.2-r3.pre-upgrade
(41/64) Upgrading php5-common (5.6.32-r0 -> 5.6.32-r2)
(42/64) Upgrading libxml2 (2.9.4-r4 -> 2.9.7-r0)
(43/64) Upgrading php5-cli (5.6.32-r0 -> 5.6.32-r2)
(44/64) Upgrading php5 (5.6.32-r0 -> 5.6.32-r2)
(45/64) Upgrading php5-curl (5.6.32-r0 -> 5.6.32-r2)
(46/64) Upgrading php5-fpm (5.6.32-r0 -> 5.6.32-r2)
(47/64) Upgrading libbz2 (1.0.6-r5 -> 1.0.6-r6)
(48/64) Upgrading libpng (1.6.29-r1 -> 1.6.34-r1)
(49/64) Upgrading freetype (2.7.1-r1 -> 2.8.1-r2)
(50/64) Upgrading libjpeg-turbo (1.5.1-r0 -> 1.5.2-r0)
(51/64) Upgrading php5-gd (5.6.32-r0 -> 5.6.32-r2)
(52/64) Replacing libintl ( ->
(53/64) Upgrading php5-gettext (5.6.32-r0 -> 5.6.32-r2)
(54/64) Upgrading php5-mysql (5.6.32-r0 -> 5.6.32-r2)
(55/64) Upgrading php5-mysqli (5.6.32-r0 -> 5.6.32-r2)
(56/64) Upgrading php5-opcache (5.6.32-r0 -> 5.6.32-r2)
(57/64) Upgrading php5-zlib (5.6.32-r0 -> 5.6.32-r2)
(58/64) Upgrading libwebp (0.6.0-r0 -> 0.6.0-r1)
(59/64) Upgrading libgd (2.2.4-r2 -> 2.2.5-r0)
(60/64) Replacing vnstat (1.17-r0 -> 1.17-r0)
(61/64) Upgrading wget (1.19.1-r2 -> 1.19.2-r1)
(62/64) Purging libressl2.5-libtls (2.5.5-r0)
(63/64) Purging libressl2.5-libssl (2.5.5-r0)
(64/64) Purging libressl2.5-libcrypto (2.5.5-r0)
Executing busybox-1.27.2-r6.trigger
Executing ca-certificates-20171114-r0.trigger
OK: 101 MiB in 64 packages

Restart the server/VM container:
# sync
# reboot

Verify it:
$ cat /etc/alpine-release

For more information see

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 3 comments/add one below):

3 comment

  1. RUN echo '' | tee -a /etc/apk/repositories \
    && echo '' | tee -a /etc/apk/repositories \
    && apk upgrade --purge

    Have a question? Post it on our forum!