Alpine linux is a linux distribution primarily made for the deploying application on linux distribution and is a rising competitor for the Ubuntu. Alpine Linux is designed for security, simplicity and resource effectivity. It is designed to run directly from RAM.
Currently, the latest version of Alpine Linux is just around 4MB which is insanely amazing. This is the main reason people are using alpine linux for releasing their application. This tiny size as compared to it most famous competitor makes Alpine Linux stand out.
The following comparison explains what make Alpine Linux distribution our topic of discussing because of its amazing tiny size but the question we all have would be how Alpine Linux achieve the following size?
The complete secrets and why the alpine linux has such a tiny image size as compared to the above yet it performs all the major operation of any other distribution here.
Alpine Linux is composed of following core components
MUSL is about 6kb in size as compared to the GNU ( glibc ) , while both are wrapper for implementation of libc having same goals which are actually a bunch of functions written in C wrapped around binary calls that make it easy to write programs. Following are some reasons and advantages over others for Musl small size:
Busybox is just around 800kb which is mainly set of shell scripts and libraries for the bash all packed in busybox. for e.g. bzip2, nslookup, wget,etc .
alpine package management can install, upgrade and delete packages. Along with that, it can also load package history from the previous state ( while rebooting system).
apk is the tool used for package management instead of apt.
link with relro, bind now & Position independant executables(PIE) - Even for static binaries, Stack smashed protector and fortify source are thing that make it more secure and safe from breaking through.
If you are using Docker than you need to have something for the OS layer then the best option is to use Alpine Linux that will reduce your image size to a bare minimum.
The truth is we don't need that many tools to deploy our application to create a Docker image. Even if you want to add more tools you can easily install it in Alpine Linux that will significantly provide you with so many benefits. A Docker container with Alpine Linux is more than perfect.
Using any other distribution will only come with unnecassary tools that are not required and if you are maintaining a private docker registery than this is the best approach.
Though, There are still cases where you would still want to go with Ubuntu most probably that will have to do with the compatability of your application but overall, Alpine Linux is pretty damn insane and you should try it out to see it live in action. Save your server costing by 87%.
Download Alpine Linux from main website here.
Let us conclude our blog here, we have explored how and why alpine Linux is going to be the default choice for developers when building a Docker Image and had a sneak peek under the hood of Alpine Linux because of which it is able to have such a small size.
Though I haven't written much about Ubuntu which will be the defacto choice for most developers we all know when coming to enterprise development, the size matters! In this case, smaller is better :)