What is Docker Alpine Linux and build-base?

Alpine Linux is a popular Linux distribution in the Docker community. Alpine's primary marketing is a distribution that is a security-oriented, lightweight, simple and based on musc libc and busybox. musc libc is,

... an implementation of the C standard library built on top of the Linux system call API, including interfaces defined in the base language standard, POSIX, and widely agreed-upon extensions

musl libc website

and busybox is an embedded centric combination of:

... tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system. BusyBox has been written with size-optimization and limited resources in mind.

busybox website

The end product is a general lightweight Linux distribution that is a great base image option for Docker containers. However, if you've come across Alpine before when creating Docker containers you've likely come across the package build-base before. A quick Google search will probably reveal this GitHub thread, which presents the build-base package as a convenient equivalent of build-essential in the Ubuntu world. But what's inside of it? Let's create a simple Dockerfile and build a container to find out!

FROM alpine

# Update the installer
RUN apk update -qq && apk upgrade

RUN apk add build-base

CMD ["sh"] 

By building this container via docker build . I am greeted with the following output (snipped for brevity):

Step 4/5 : RUN apk add build-base
(1/18) Installing libgcc (9.2.0-r4)
(2/18) Installing libstdc++ (9.2.0-r4)
(3/18) Installing binutils (2.33.1-r0)
(4/18) Installing libmagic (5.37-r1)
(5/18) Installing file (5.37-r1)
(6/18) Installing gmp (6.1.2-r1)
(7/18) Installing isl (0.18-r0)
(8/18) Installing libgomp (9.2.0-r4)
(9/18) Installing libatomic (9.2.0-r4)
(10/18) Installing mpfr4 (4.0.2-r1)
(11/18) Installing mpc1 (1.1.0-r1)
(12/18) Installing gcc (9.2.0-r4)
(13/18) Installing musl-dev (1.1.24-r2)
(14/18) Installing libc-dev (0.7.2-r0)
(15/18) Installing g++ (9.2.0-r4)
(16/18) Installing make (4.2.1-r2)
(17/18) Installing fortify-headers (1.1-r0)
(18/18) Installing build-base (0.5-r1)
Executing busybox-1.31.1-r9.trigger
OK: 177 MiB in 32 packages

libgcc is part of GCC's low-level runtime library that contains helpers for arithmetic operations, error handling and miscellaneous operations.

libstdc++ is the GNU Standard C++ Library v3.

bintuils is a collection of "binary tools"

file is Unix and Unix-like operating systems for recognizing the type of data contained in a computer file.

gmp is a C arithmetic precision library

isl is a C "integer set library"

libgomp is a C multi processing runtime library

libatomic is a C atomic operations library

mpfr4 is a C "multiple-precision floating-point computations with correct rounding" library

mpc1 is a "multi precision" C library

gcc is the GNU Compiler Collection

musl-dev is the musl c library implementation with development files.

libc-dev is a "meta package" for libc

g++ is the GNU C++ Compiler

make is the GNU make utility

fortify-headers is a compile time buffer check library; and finally