Preparation
I am using a Jiffybox provided by DomainFactory for building a Docker container for Kolab 3.1 running on CentOS 6.
I have installed Ubuntu 12.04 LTS on a Jiffybox.
I am therefore following Docker Installation instructions for Ubuntu for the installation instructions:
Install a kernel that is required by Docker:
sudo apt-get update sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring |
After that, in the admin website of JiffyBox, select the custom kernel Bootmanager 64 Bit (pvgrub64); see also the german JiffyBox FAQ. Then restart your JiffyBox.
After the restart, uname -a
should show something like:
Linux j89610.servers.jiffybox.net 3.8.0-37-generic #53~precise1-Ubuntu SMP Wed Feb 19 21:37:54 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux |
Now install docker:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" sudo apt-get update sudo apt-get install lxc-docker |
Create a Docker image
I realised that if I would install Kolab in one go, the image would become too big to upload to https://index.docker.io.
Therefore I have created a Dockerfile which has several steps for downloading and installing various packages. For a detailed description of a Dockerfile, see the Dockerfile Reference
My Dockerfile looks like this:
FROM centos RUN mv /etc/localtime /etc/localtime.old; ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime RUN echo "NAME=kolab31.test.example.org" > /etc/sysconfig/network; echo "kolab31.test.example.org" > /proc/sys/kernel/hostname RUN chmod a+w /dev/shm WORKDIR /root RUN wget -O master.tar.gz https://github.com/tpokorra/kolab3_tbits_scripts/archive/master.tar.gz; tar xzf master.tar.gz; rm master.tar.gz WORKDIR /root/kolab3_tbits_scripts-master/kolab3.1 RUN sed -i -e "s/^yum -y install kolab.*/#yum -y install kolab/" reinstallCentOS.sh RUN echo "y" | ./reinstallCentOS.sh CentOS_6 # split yum -y install kolab into several steps, # to keep the revisions small enough to avoid problems with uploading the image RUN yum -y install php-kolabformat RUN yum -y install mysql-server RUN yum -y install kolab-cli RUN yum -y install kolab-imap RUN yum -y install 389-ds-base RUN yum -y install java-1.6.0-openjdk RUN yum -y install libgcj RUN yum -y install kolab-ldap RUN yum -y install kolab-webadmin RUN yum -y install iRony RUN yum -y install wallace RUN yum -y install kolab-webclient RUN yum -y install postfix RUN yum -y install clamd RUN yum -y install kolab-mta RUN yum -y install qt-x11 RUN yum -y install libkolab RUN yum -y install kolab patch unzip # prepare for setup kolab RUN ./initSetupKolabPatches.sh # we cannot run setup-kolab here, because the hostname is no FQDN # RUN setup-kolab --default --timezone=Europe/Brussels --directory-manager-pwd=test # allow connections on port 443 (https) EXPOSE 443 # TODO: allow IMAP as well #CMD ["/sbin/init"] |
This command will build a container with the instructions from the Dockerfile in the current directory. When the instructions have been successful, an image with the name tpokorra/kolab31_centos6 will be created, and the container will be deleted:
sudo docker build -t tpokorra/kolab31_centos6 . |
You can see all your local images with this command:
sudo docker images |
To finish the container, we need to run setup-kolab, this time we define a hostname as a parameter:
MYAPP=$(sudo docker run --name centos6_kolab31 -h kolab31.test.example.org -d -t -i tpokorra/kolab31_centos6 /bin/bash) docker attach $MYAPP # run inside the container: echo `hostname -f` > /proc/sys/kernel/hostname setup-kolab --default --timezone=Europe/Brussels --directory-manager-pwd=test ./initSSL.sh cat > /root/start.sh << EOF #!/bin/bash service httpd start service mysqld start service dirsrv start service cyrus-imapd start sleep 10 service kolabd start service kolab-saslauthd start EOF chmod a+x /root/start.sh service kolabd stop service dirsrv stop service cyrus-imapd stop service mysqld stop service httpd stop exit |
Typing exit inside the container will stop the container.
Now you commit this last manual change:
docker commit $MYAPP tpokorra/kolab31_centos6 # delete the container docker rm $MYAPP |
You can push this image to https://index.docker.io:
#create a new account, or login with existing account: sudo docker login sudo docker push tpokorra/kolab31_centos6 |
You can now see the image available here: https://index.docker.io/u/tpokorra/kolab31_centos6/
See this post Installing Demo Version of Kolab 3.1 with Docker about how to install this image on the same or a different machine, for demo and validation purposes.
Current status: There are still some things not working fine, and I have not tested everything.
But this should be a good starting point for other people as well, to help with a good demo installation of Kolab on Docker.