Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Docker Tip #9: Installing Popular Packages on Alpine

blog/cards/docker-tips-and-tricks.jpg

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:
DISTRIBUTIONPACKAGE MANAGER COMMAND
Alpineapk
Archpacman
Debian / Ubuntuapt
CentOS / RHELyum
Fedoradnf

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.

PURPOSEALPINEDEBIAN / UBUNTU
Connecting to PostgreSQLpostgresql-devlibpq-dev
Connecting to MySQL / MariaDBmariadb-devlibmysqlclient-dev
Interacting with Imagemagickimagemagick-devimagemagick
Dealing with bcryptlibffi-devlibffi-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.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.


Comments