Skip to content

Alpine Linux

Created: 2019-01-11 11:00:38 -0800 Modified: 2019-01-21 09:00:40 -0800

Alpine is a very thin image, so it’s desirable by many packages to use as a base image. There are some things that you should know:

  • You can figure out your Alpine version by going on Docker Hub and seeing what the base image you have uses. For example, I had “FROM node:8.12-alpine” as the first line of my Dockerfile. I went to Docker Hub, searched for Node (giving me this), then searched for the tag 8.12.0-alpine (which gave me this), and I saw Alpine was version 3.8 in that image.
  • Once you know your Alpine version, you can figure out which version of a package APK will install by looking at a page like this:*yarn*&branch=v3.8
  • APK tips
    • General usage: $ apk update && apk add sudo
  • The shell on Alpine is “ash”, not “bash”.
  • To add users/groups, look at this troubleshooting section.
  • Sometimes performance on Alpine may not be the same as on another OS, e.g. Debian. Alpine uses musl libc instead of glibc, which at least historically has sometimes led to performance issues, e.g. here.
  • Sample installation of Yarn on Alpine (note: you should never have to install Yarn if you’re using node-alpine; it tends to mean that you’ve done something wrong)

apk add curl

curl -o- -L | ash -s

export PATH=“HOME/.yarn/bin:HOME/.yarn/bin:PATH”

Note: if you want a specific version of Yarn, specify this for the “ash” part: ash -s — —version 1.10.1