base64 images in HTML pages

I have found out that it is possible to embed images in a HTML page as base64 strings! I like the idea of having everything as text. I use it to display the favicon on the front page of my web site.

This is very easy:

Convert your favicon to base64:

$ base64 -w 0 favicon.ico

The -w switch is to have the whole string as a single line.

Include this entry in the <head> section of your HTML page:

<link href="data:image/x-icon;base64,AAABAAE...fAAD//wAA" rel="icon" type="image/x-icon" />

I cut the base64 string a little for better visibility.

Another cool use of base64.


Debloat docker

I recently read about docker wanting to move all their official images from the likes of Debian/Ubuntu/CentOS to Alpine Linux. This is a fantastic idea!

Alpine is very small, it is similar to the busybox image, but it includes a package manager (apk, similar to apt-get and yum) and the distribution provides about 6,000 packages, including openjdk (a must for a Spring developer like me).

The micro images are very easy to use, we go back to the roots of Linux, before systemd, even before sysv 😉 Alpine is now my base image for everything except when I need to have glibc, that is to say when I need to run binaries compiled against it, and it would be too much hassle to recompile against musl (the libc used by Alpine).

Busybox HTTPD

I love busybox. It is super simple to compile, fully customizable. It even includes a web server! These are the steps I took to make it work, from source.

Make sure you have the following packages installed on your machine: git, gcc, make

Clone the repo:

$ git clone git://

Compile the source:

$ cd busybox
$ make defconfig
$ make

If you have multicore, you can speed up compilation by running (for example if you have 4 cores):

$ make -j 4

Once done, you have an executable called ‘busybox’. Run it and you will see all the commands included. You run a command as follows, for example to open a vi text editor:

$ ./busybox vi

Now, to run a web server, the command is called httpd. Each command has a short help, called with the –help switch. For httpd:

$ ./busybox httpd --help
BusyBox v1.25.0.git (2016-02-11 12:45:41 GMT) multi-call binary.

Usage: httpd [-ifv[v]] [-c CONFFILE] [-p [IP:]PORT] [-u USER[:GRP]] [-r REALM] [-h HOME]
or httpd -d/-e/-m STRING

Listen for incoming HTTP requests

        -i              Inetd mode
        -f              Don't daemonize
        -v[v]           Verbose
        -p [IP:]PORT    Bind to IP:PORT (default *:80)
        -u USER[:GRP]   Set uid/gid after binding to port
        -r REALM        Authentication Realm for Basic Authentication
        -h HOME         Home directory (default .)
        -c FILE         Configuration file (default {/etc,HOME}/httpd.conf)
        -m STRING       MD5 crypt STRING
        -e STRING       HTML encode STRING
        -d STRING       URL decode STRING

So, you can launch a web server for example like this:

$ ./busybox httpd -p 8000 -h /path/to/www/pages

There are many more possibilities, including setting up mime types, running CGI scripts etc. More information can be found on the OpenWrt wiki site where the configuration file is explained in details.