Getting Started in Alpine Linux
The thing that was really intriguing for me in the article was the image size of the public image size:
Wow, Alpine Linux is dramatically smaller than almost everything on the list, especially my default distribution: Ubuntu.
This made me think: if I’m including a Vagrantfile to install a whole virtual machine to run my projects, picking a small one will help:
- download times - smaller distribution, less download, less waiting.
- setup times - even using the downloaded image, vagrant will make a copy.
- disk space - smaller is better, especially since I’m basically using the virtual machine as a “deploy appliance”.
So, I jumped into alpine Linux with vagrant.
Getting Vagrant Images
The Vagrant Boxes page lists available Alpine Linux boxes that vagrant can use.
Initially, I used the
generic/alpine3.6 image as
it was the most recently updated, but found one main issue: it did not support
shared folders in vagrant. I tried to configure it via:
config.vm.shared_folders option and reading through the Virtualbox section on
the wiki, but
there seemed to be something about virtualbox guest additions I could not get
working properly. If shared folders are not needed, the generic/alpine3.6 image
is fine. (If you know how to get it working, let me know!)
Currently, 3.6 is the current version of alpine linux and I went with this image maier/alpine-3.6-x86_64. The notes page lists it has support for virtualbox guest additions. So there seems to be something done in this image but not in the generic/alpine3.6 image.
Installing Alpine Linux
I started with this Vagrantfile:
Ok, nothing special so far.
Let’s look at the amount of drive space this took:
Hmm… not bad, 550MB. Wow, that makes me wonder, how much space does Ubuntu 14.04 (Trusty Tahr) use?
Oh wow… a basic install of Ubuntu Trusty is using 1.47GB, almost three times more than alpine??
Ok, Alpine Linux just got me interested just based on this.
Let’s look inside and compare process list through HTOP:
Not bad, 21 tasks using 20MB of RAM.
Let’s check what it is on Ubuntu/Trusty:
Ok, 30 tasks, 40% more than alpine. But wow, look at the memory usage: 118MB. This is 6x more than alpine.
This is enough convincing for me, how do I get started using alpine more?
Well, Alpine linux is a barebones linux. It has only a handful preinstalled
items. It uses a different package manager than
apt, which I’m comfortable in.
The Emacs Test
As a test, I always like to see how to install emacs on a system.
To install things in apk, alpine’s package manager, the command is:
apk add <package>.
With Emacs installed, I have most of the tools to do work on Alpine Linux.
I like using emacs as a test for package management. It’s a piece of software that has enough users that almost every system will have it, but default installtion is not guaranteed.
For those curious, yes, vi is on Alpine Linux, although it seems to be version
1.26.2 2017-08-03 13:08:12 GMT.
Package Add ERROR
Originally, on generic/alpine3.6, to install emacs, I tried:
sudo apk add
emacs and got this response:
It took some poking around and I learned:
apk add <package> defaults to
repositories without #@# in the name. The generic/alpine3.6 image has a
/etc/apk/repositories listing of:
So, to add things from the #community# or #edge# repository, add @community or @edge the package name to match the leading indicator. The maier/alpine-3.6-x86_64 image includes the community repository by default.
To find out what packages are part of alpine linux and in what repository, this page provides a full list with search:
This page lists emacs support.
Looking at the Architectures column for the packages, I realize the number of computing architectures supported by Alpine Linux. The architecture wiki page lists six different computing architectures:
- 2 x86 based (32bit and 64bit)
- 2 ARM based (32bit and 64bit)
- 1 PowerPC based (64bit)
- 1 IBM System Z based (s390x)
This was a quick comparison of resource usage of Alpine Linux in a virtual machine environment using vagrant.
As Alpine Linux has 1/3 of the disk storage requirements, 1/6 the RAM usage, and 40% fewer tasks than Ubuntu 14.04 (Trusty Tahr), I will focus on using Alpine Linux as my default system image for my projects.
Alpine Linux’s package management system, apk, is pretty straight forward, as it can install emacs easily. :-)
With this knowledge, I will start using Alpine Linux in my projects and maybe try it out full time.