Alpine Linux Repositories
Native packages for Alpine Linux are installed via software repositories that are configured on the system. This document explains how to configure Alpine-native repositories. For Flatpak repositories, please see the Alpine Linux Flatpak wiki article.
Repository Basics
To use an Alpine Linux native software repository, you need two things:
- An entry for the repository in the /etc/apk/repositories file, and
- The RSA public key(s) used to sign the repository package index.
As long as you have an Internet connection to your Alpine system, you can run the command:
setup-apkrepos
You can just press Enter to accept the default mirror, which is Alpine’s Content Delivery Network (CDN).
This command will set up the basic Alpine “main” package repository, producing an /etc/apk/repositories file that looks something like this:
http://dl-cdn.alpinelinux.org/alpine/v3.21/main
#http://dl-cdn.alpinelinux.org/alpine/v3.21/community
NOTE: If you’re using a different version of Alpine Linux, the v3.21 part of the URL will be different. Make the appropriate substitutions in the rest of these instructions.
The RSA public keys for the official Alpine repositories are already included on the system by the alpine-keys package.
Editing the Repositories File
To make changes to the repositories file, edit it as the root user by running:
vi /etc/apk/repositories
Blank lines in this file are ignored. Lines that start with the # symbol are comments.
One simple edit that you can perform is to change the http mirrors to https. With these edits, the sample above would look like the following:
https://dl-cdn.alpinelinux.org/alpine/v3.21/main
#https://dl-cdn.alpinelinux.org/alpine/v3.21/community
Technically, the RSA signing procedure protects your downloads even with a “plain” HTTP mirror. However, use of HTTPS for all HTTP-protocol traffic is considered a modern best practice in part to reduce the amount of information your ISP can collect about your activities online.
Enabling the Community Repository
Quite a few useful Alpine Linux packages are available in Alpine’s community repository. To make these packages available, edit your /etc/apk/repositories file to look like this:
https://dl-cdn.alpinelinux.org/alpine/v3.21/main
https://dl-cdn.alpinelinux.org/alpine/v3.21/community
If you started from the above sample file, the only needed change was to remove the comment symbol from the beginning of the line showing the community repository.
Save your file and exit Vi. Update the repository metadata by running:
apk update
Adding the Testing Repository
New packages in Alpine Linux typically start in the testing repository and are moved to the community repository if they are sufficiently popular and properly built. It is not safe to enable the testing repository unconditionally, since newer versions of packages found in that repository might break your system. Instead, we need to tag the repository so that only specific packages can be installed from it. The line in the /etc/apk/repositories file to do this would be:
@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing
To install a package named some-package from the testing repository, you would run:
apk update
apk add some-package@testing
Note that installing packages from the testing repository tends to break toward the middle of a release cycle if you’re running a stable release. This is normal, since packages in testing are always built against the rolling “edge” version of Alpine, which you probably do not want to run due to its instability.
Adding a Third-Party Repository
If you have access to a third-party repository, you can add it by adding its key(s) and an entry in /etc/apk/repositories. For the sake of this example, we will add the Coastal Carolina University “tealrepo” repository to our system. To begin, we first need to download the public RSA key into the /etc/apk/keys directory:
cd /etc/apk/keys
wget https://mirror.coastal.edu/tealrepo/teal-repo%40coastal.edu-66dcca7c.rsa.pub
Now we can edit /etc/apk/repositories and enable this repository by adding the line:
https://mirror.coastal.edu/tealrepo/packages/v3.21
Optionally, you could tag this line by putting @tealrepo in front of it (or something other unique word that starts with @). Since we build packages for stable versions of Alpine, however, this particular repository doesn’t actually need to be tagged.
To use this repository, simply update repository metadata and install packages from it. For example, to install our linux-desktop package (which contains a Linux kernel with drivers enabled for desktop/laptop systems and good USB device coverage), run:
apk update
apk add linux-desktop
If you tagged the repository, the second command would be:
apk add linux-desktop@tealrepo