Docker Tip #9: Installing Popular Packages on Alpine
Alpine is a lightweight Linux distribution. Learn how to install a few packages that are commonly found in web applications.
A few days ago I wrote about the 3 biggest wins when using Alpine as a base Docker image, so now you might be wondering how to use it.
If you’ve been using Debian, Ubuntu, CentOS or another distribution for a long time, then chances are you’re familiar with what packages your applications need and how to install them.
Here’s a package manager comparison:
DISTRIBUTION | PACKAGE MANAGER COMMAND |
Alpine | apk |
Arch | pacman |
Debian / Ubuntu | apt |
CentOS / RHEL | yum |
Fedora | dnf |
To manage packages with Alpine, you’ll want to run apk
commands.
Next up, here’s a list of popular packages that you may end up installing for various web applications. I’ve included the Debian / Ubuntu alternative for easy reference.
Popular Alpine package names compared to Debian / Ubuntu:
PURPOSE | ALPINE | DEBIAN / UBUNTU |
Connecting to PostgreSQL | postgresql-dev | libpq-dev |
Connecting to MySQL / MariaDB | mariadb-dev | default-libmysqlclient-dev |
Interacting with Imagemagick | imagemagick-dev | imagemagick |
Dealing with bcrypt | libffi-dev | libffi-dev |
The above are packages that I end up installing once in a while for various web
apps. To install one of them you would run apk add postgresql-dev
, etc..
It is not meant to be a comprehensive list. If you have any packages that you would like to see listed let me know in the comments below.
I’ve had a lot of luck with just Googling for “libpq-dev for Alpine” (and similar), so feel free to use that tactic when looking for Alpine package names when you know what they are in another distribution.
Also, if you happen to run into an “unsatisfiable constraints” error, that usually means the package you’re trying to install doesn’t exist.