Converting docker containers into AppImages

Written by

in

In Linux, packages are the conventional way to distribute software. These packages are usually made of executable files, scripts and various other files. Examples include RPMs and Deb archives. While very useful, these packaging formats have a downside: they are distribution specific. Even if two distributions use the same packaging format, for instance Ubuntu and Debian, they are not compatible. Even further, packages may not be compatible between two different releases of the same Linux distribution, for instance Debian stable and Debian unstable. Consequently software, on Linux, needs to be built for every combinations of Linux distribution / releases out there.

For simple open source software, like terminal applications, this isn’t usually a big issue, as volunteers can usually take the code and release it for the distribution of their choice making small adjustments to the code (at least in principle). For more complicated software and proprietary software this is trickier. However there is a solution to this problem: open source developers have created various universal packaging formats. The main ones are Flatpak, Snaps and AppImage. But there are many others, technically Docker is also a mean to distributed software. One can count also Steam distributables, if you think about it. And even Nix packages are in some way distribution agnostic as you can install Nix on many Linux distributions.

I personally think AppImage lacks a little bit of love. It does not offer as many features as Flatpak or Snaps, which handle sand-boxing, software distribution, and sharing frameworks, but it is very simple and easy to grasp. AppImages are already fairly popular amongst QT applications, electron applications, and even some games like OpenRA. However there are few tools to create AppImages. So I decided to create another tool, which creates AppImages from Docker containers. Furthermore, there is plenty documentation on creating Docker images and the collection of publicly available Docker images is very large. The tool’s name docker2appimage available on Github at https://github.com/mparusinski/docker2appimage.

Using docker2appimage

If you have a container called relaxed_beaver, to create an AppImage from this containers, triggering default command, you run.

docker2appimage relaxed_beaver

You can perform more complex tasks like request docker2appimage to create an AppImage named alpine-ls from the alpine Docker image that calls ls

docker2appimage -x ls --name alpine-ls -i alpine

In order to work the tool requires the appimagetool AppImage as well imagemagick to be installed on the system. The entire tool, in order to be portable, is a simple shell script.

Here is an even more complex example where we create an universal binary for ripgrep a popular alternative for grep:

docker run -dit --name=ripgrep ubuntu bash
docker exec -i ripgrep bash <<'EOF'
  apt-get update
  apt-get install -y ripgrep
EOF
docker2appimage -x rg ripgrep

Most Docker images are server side software (e.g. nginx), OS containers (e.g. alpine) and programming frameworks. Naturally docker2appimage will fit well to create CLI-only AppImage although it is possible to create GUI based AppImages as well.

Shortcomings and next steps

There are some limitations of course. Many Docker images default commands are shells like bash, sh, … one might even include Python as a type of shell. AppImage works by using environment variables and Fuse to create a pseudo virtual environment; this virtual environment is then used to launched commands. As a result, handling shell commands is tricky and right now is not supported.

The project is still ongoing development to support many applications and Linux distributions. If you have some time and are curious do not hesitate to test the tool and report any bugs you see.

Comments

Leave a Reply