Install and run Freenetis in a Docker container

According to wikipedia, Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux.

Freenetis is an open source information system for managing community networks.

Why to learn Docker and container technologies in general?

I am fascinated with the idea behind the Docker. It enables you to just create your own docker image with your application and you don’t have to care about deployment details at all. It can be deployed locally, on your server or directly into a cloud. So the first benefit is the significant reduce of requirements with respect to deployment.

You can achieve isolation benefits like with virtual machines, but with significantly smaller overhead and memory footprint. Docker allows you to use configuration as a code – so called Dockerfile – which is lightweight and makes it easy to share container definitions. It also offers simple way to distribute ready-to-deploy containers.

There are also disadvantages, it is currently targeted more only to Linux hosts and images, but this may change in time.

Current possibilities to install Freenetis

Freenetis can be installed currently in two ways. Either it can be installed directly by checking out sources and configuring everything from scratch or it can be installed automatically using the provided deb packages. The first option is substantially difficult and requires deep knowledge of the Freenetis system. The second option to use prepared deb packages is much more user friendly.

I currently use Fedora on my laptop and it uses rpm packaging system. So there is currently no simple way to install Freenetis on my machine, as the only option for me is to install manually from the sources. However there is a solution. I can install Docker, pull there an image of Debian operating system, start the image as a container and install there Freenetis using the steps provided. Currently only in Czech. That’s it! I don’t have to install heavy-weight full virtualization of Debian.

Installing Docker

The first thing is to install docker. The following commands are applicable and were tested on Fedora 20. You need to install docker-io package. To make further work easier, it is convenient to add a system user to a docker group, that will make your life easier and you will not have to work ordinarily with Docker as a superuser.

# yum install docker-io
# usermod -a -G docker user_id

We can look for all debian images available in a central repository and install the basic one with the second command:

$ docker search debian
$ docker pull debian

I have to mention several useful commands here. The first one is to list currently installed Docker images and the second one is to remove unnecessary images. This will be useful, as after each update of the upstream Docker image, the old one is preserved.

$ docker images
$ docker rmi c9fa20ecce88

The last command is to check if the image is working properly. It should print the content of a default directory:

$ docker run -t debian ls

Installing Freenetis

At the beginning the container already needs to be running, we can achieve this by starting the container in interactive mode:

$ docker run -it -p 12345:80 debian /bin/bash

Remember that all changes done after starting the container are automatically lost. To save them, we need to create a container snapshot and save it as a new image. That’s why number of container images may grow quickly and it is useful to use Dockerfiles or run commands in batch. Let’s return to the command itself. Container will be run in interactive mode, with a new console open in the same terminal window. Port 80 of the container will be mapped to port 12345 of the host system. Console of the container will be started by definining the last command, which tells the docker to start bash console in the container.

Let’s install necessary tools for installation:

root@fa644d58b14:/# apt-get update && apt-get install vim wget

We have to add new Debian package repository:

root@fa644d58b14:/# vim /etc/apt/sources.list
deb http://repository.freenetis.org/debian/stable/ wheezy main

Then we can install Freenetis itself:

wget -O - http://repository.freenetis.org/debian/freenetis_repo.gpg.key | apt-key add -
apt-get update && apt-get install freenetis

During Freenetis installation I chose option one to install Freenetis into location http://localhost/freenetis.

In the end I had manually start Apache 2 httpd server:

root@5949a66e334c:/# service apache2 start

Now I am ready on my host computer to access Freenetis installed on the following page http://localhost:12345/freenetis.

Summary

In this article I’ve tried to sum up benefits of container technologies and Docker in particular. My current aim is to install Freenetis easily on unsupported non-debian system like Fedora. However the implications of Docker are big, for example a cloud that supports Docker should be easily able to consume images containing Freenetis. So try it now and let me know your feedback, I’ll appreciate it!

Leave a comment