SOGo in Docker container on QNAP TS-453mini

The QNAP ContainerStation allows to run LXC and Docker containers. According to the Internet, this should be less resources consuming than virtualization via KVM.

Here’s how I run SOGo in a docker container.

Create the container

From the QTS App Center, locate and install ContainerStation. When done, launch it from the desktop panel.

On the left panel, click the “+ Create Container” link. In the “Search Images” text zone, enter “ubuntu”. Locate the “Ubuntu DOCKER” object and click “Create”.

Name the container as you like and set resources restrictions if you think it’s safe. In the advanced settings, I like to setup a hostname inside the jail container to know where I am during console sessions. In the network settings, I use the “Host” mode so that I don’t have to NAT the services. When all is done, just click “Create”. In seconds, the container is created and has been associated an ID.

From there, you can interact with the container via the console box. Or you can SSH to the QNAP and issue the following commands:

# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
377405f05102 ubuntu:14.04 "/bin/bash" 7 minutes ago Up 7 minutes SOGo

# docker exec -it 377405f05102 bash
root@docker-sogo:/# uname -a
Linux docker-sogo 3.12.6 #1 SMP Wed Jun 1 03:23:51 CST 2016 x86_64 x86_64 x86_64 GNU/Linux
root@docker-sogo:/#

Accessing the container this way allows standard interaction from a Terminal. I have issues with some key bindings using the HTML console (and a french Mac keyboard).

Install SOGo

First add the repository for SOGo. And install the package.

root@docker-sogo:~# tail /etc/apt/sources.list
# SOGo on Ubuntu Trusty Tahr (14.04)
deb http://inverse.ca/ubuntu-v3 trusty trusty

root@docker-sogo:~# apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
root@docker-sogo:~# apt-get update
root@docker-sogo:~# sudo apt-get install sogo
(...)
Setting up sogo:amd64 (3.1.2-1) ...
(...)

Then, create the configuration file. In my case, I’m migrating from an Ubuntu virtual machine using QNAP Virtualization Station. So I can take the original sogo.conf file and copy it to the container’s filesystem.

admin@qnap:~# docker cp sogo.conf.bz2 377405f05102:/etc/sogo/
root@docker-sogo:~# bunzip2 -f /etc/sogo/sogo.conf.bz2
root@docker-sogo:~# chown sogo:sogo /etc/sogo/sogo.conf
root@docker-sogo:~# chmod 0640 /etc/sogo/sogo.conf

root@docker-sogo:~# egrep -v "^$|^#" /etc/default/sogo
PREFORK=10

Finally, check everything starts and works properly and set auto-start.

root@docker-sogo:~# service sogo start
 * Starting SOGo sogo [ OK ]
root@docker-sogo:~# update-rc.d sogo enable

Install and configure the Web Server

Accessing SOGo requires a Web server. I usually configure Apache to publish SOGo. In this case, I’ll use nginx ; just because it is possible to do so!

root@docker-sogo:~# sudo apt-get install ngnix
root@docker-sogo:~# rm /etc/nginx/sites-enabled/default
root@docker-sogo:~# vim /etc/nginx/sites-enabled/sogo.conf
# Check remote http://wiki.sogo.nu/nginxSettings for inspiration
(...)
root@docker-sogo:~# service nginx start
root@docker-sogo:~# update-rc.d nginx enable

In my case, the container listens on ports 20000 (for SOGo) and 20080 (for nginx). That allows me to use the “bridge” feature of docker. A reverse-proxy can publish SOGo (and other things) using redirection from HTTPS/443 to TCP/20080.

Et voilà! SOGo is now running in a docker container instead of full virtual machine.

No Comments

Leave a Reply

%d bloggers like this: