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|
|Debian / Ubuntu|
|CentOS / RHEL|
To manage packages with Alpine, you’ll want to run
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|
|Connecting to MySQL / MariaDB|
|Interacting with Imagemagick|
|Dealing with bcrypt|
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.