Build Alpine Linux 3.10.3 Docker Image

Prerequisites

An Alpine environment is required to build an Alpine Docker image. An Alpine WSL setup under Windows can be used or run an Alpine Docker image from hub.docker.com.

docker run -it alpine:3.10 /bin/sh

Setup build environment

Run the following commands in your Alpine environment (as root user):

# apk add alpine-sdk linux-headers libcap-dev alpine-make-rootfs # addgroup root abuild # abuild-keygen -a -i

Note that you must be in the abuild group to build the apk packages, so you may need to open a new root shell:

# sudo su -

Compile

The Alpine Docker image requires downloading the alpine-keys, musl, busybox, alpine-baselayout, ca-certificates, pax-utils, apk-tools, libtls-standalone, openssl and zlib aports packages. To build a local copy of each package:

# mkdir apk source # for i in alpine-keys musl busybox alpine-baselayout ca-certificates pax-utils \ apk-tools libtls-standalone openssl zlib; \ do \ (cd $i; abuild -P ~/apk -s ~/source -R -F); \ done

Generate Docker image

To create the Docker image:

APK_OPTS=~/source alpine-make-rootfs --branch v3.10.3 --packages "apk-tools alpine-keys" -- - | docker import -c 'CMD /bin/sh' - alpine:3.10.3