What is Alpine Linux?

Explore the basics of Alpine Linux and discover its often-used components.

Preface

Alpine Linux is one of the most popular Linux distributions available, especially in containerization. It has over a billion downloads on Docker Hub, and many existing Docker images are based on the original Alpine images. Many popular projects also offer Alpine Linux flavors of their image, like Python, PostgreSQL, and Redis.

Alpine Linux components

Alpine Linux consists of some often-used components, which are explained below.

The apk component

The apkAlpine Package Keeper component (not to be confused with the .apk package format of Android apps) is the package manager of Alpine Linux. It’s used for all basic package operations, like adding, removing, and upgrading packages. Like the rest of Alpine Linux, apk is designed to be as fast as possible while being easy to use. As such, updating the repositories and installing a small package only takes a few seconds compared to a minute or longer with alternative package managers like apt. Common apk commands are:

Press + to interact
apk add example # Install the package "example"
apk del example # Remove the package "example"
apk update # Update repositories
apk upgrade # Upgrade packages

The abuild component

The abuild component is used to build .apk packages that can be installed with apk. We will use it in future lessons to build our packages.

The musl libc

A significant distinction of Alpine Linux compared to traditional distributions is that it uses musl libc instead of glibc, which is used by other distributions, like Debian or Fedora. This has some advantages:

  • With musl, proper statically linked versions of programs can be created that are entirely self-contained. This allows binaries to be compiled on Alpine Linux and then run on (almost) any other Linux distribution. This isn’t possible with glibc.
  • The musl strives to be POSIX compliant and is a generally a more straightforward implementation of the POSIX C spec than glibc. This aids in debugging when musl implementation is easier to understand.

However, it also comes with some drawbacks:

  • Programs compiled against glibc can’t be easily executed in Alpine Linux. This means that most proprietary software doesn’t run on Alpine Linux.
  • Some open-source projects use C extensions specific to glibc. These projects don’t compile and run on musl.