You are not logged in.

#1 2015-11-28 11:11:31

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 80
Website

arch-docker - building docker image with Arch Linux

I have been spending my time lately creating the docker image with and using Arch Linux. I documented the process here [1]. I will just copy the conclusion here,

Finding and creating the smallest possible base docker image using Arch Linux is possible, with minimum size roughly around ~90 MB, and it depends on your use case or how do want the image to be used. You don't need Dockerfile to do it. In my use case I prefer not to installing pacman in image, if I want to create an image for another use case, I will just run pacstrap and install all the required packages.

If we want a better lightweight image, not just in docker but in normal system, while still using Arch, there is no other way than modified the original package, i.e. splitting between doc, devel, and locales; and minimize the dependencies between packages by splitting them into only more specific function. For example, sha*sum binaries could be split into openssl-tools, not as part of coreutils. If only the Arch package maintainers care about size and function, this would be easy since the start, no manual cleaning and no force-remove packages.

If you want a better lightweight image for your docker, there is no other way than stiching it by hand and create it manually using rootfs.

It started from just simple script using pacstrap and became a several scripts that can be modularized. So, to create another image with specific packages we can just change the variable, add package name and run the script. You can view the finished scripts here [2].

It faster than building with Dockerfile (since docker use some caching mechanisme for each command which result in one image can contain several cached images), plus you can modified the rootfs manually before creating the image. Here is the list of images size for comparison,

REPOSITORY                 TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
sulhan/arch-nodejs         latest              ac73cf5c1d36        54 minutes ago       351.6 MB
sulhan/arch-redis          latest              a2de7d62a807        58 minutes ago       100.5 MB
sulhan/arch-postgresql     latest              5568162e33a0        About an hour ago    129.6 MB
sulhan/arch-base           latest              2af8f94bb6b7        About an hour ago    86.92 MB

The arch-base is only bash with minimum dependencies. The arch-postgresql is arch-base + postgresql. The arch-nodejs is arch-base plus git, gcc, make, python2, nodejs, and npm.

After pushing to my docker hub [3], I am a little bit surprise that the website said that for my arch-base the image size is 32 MB instead of 86 MB [4], and my arch-postgresql is only 49 MB not 128 MB. I have no idea why they were different.

[1] http://kilabit.info/journal/2015/11/Bui … Arch_Linux
[2] https://github.com/shuLhan/arch-docker
[3] https://hub.docker.com/r/sulhan/
[4] https://hub.docker.com/r/sulhan/arch-base/tags/

Last edited by ms (2015-11-28 12:16:21)

Offline

#2 2015-11-29 00:14:46

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: arch-docker - building docker image with Arch Linux

You can also just use the NoExtract option in pacman.conf

$ grep NoExtract /etc/pacman.conf
NoExtract   = usr/share/doc/*
NoExtract   = usr/share/help/*
NoExtract   = usr/share/locale/*
NoExtract   = usr/share/man/* !usr/share/man/man*
NoExtract   = usr/share/vim/vim74/lang/* usr/share/licenses*
NoExtract   = usr/bin/modprobed_db
NoExtract   = etc/pacman.d/mirrorlist

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB