What is Alpine Linux?
Explore the basics of Alpine Linux and discover its often-used components.
We'll cover the following
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 apk
.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:
apk add example # Install the package "example"apk del example # Remove the package "example"apk update # Update repositoriesapk 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 withglibc
. - The
musl
strives to bePOSIX
compliant and is a generally a more straightforward implementation of thePOSIX
C spec thanglibc
. This aids in debugging whenmusl
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 onmusl
.