×


Deploy Zimbra Collaboration using docker

Are you trying to know how to run Zimbra on Docker Container?

This guide is for you.


A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform docker related tasks.

In this context, you will learn steps to run Zimbra on Docker container on CentOS 7 base image.


Benefits of Zimbra on Docker Container ?

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. It consists of a Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub.


Cloud service for sharing applications and automating workflows, Docker enables apps to assemble quickly from components. In addition, it eliminates the friction between development, QA, and production environments.


Advantages of using Docker and the ZimbraEasyInstall Script includes:

i. Time-saving.

ii. Fully automated.

iii. Easy to use.

iv. Great for a quick Zimbra Preview.


Next, we will see how to automate Zimbra installation on Docker.


More about Dockerizing Zimbra ?

First, we need to install Docker on the server we use as a host for the docker containers.

One advantage of docker is that the host OS does not matter, the containers will work on any platform.

Before Dockerizing Zimbra, we create a user-defined docker network for Zimbra. This enables us to define an IP address for the container.


On this setup, the bridge we create is, zimbra_bridge and the network subnet is ipaddress/24 using the command:

# docker network create -d bridge –subnet ipaddress/24 zibra_bridge


Then we confirm the network creation was successful using:

# docker network ls


NETWORK ID NAME DRIVER

f16cc34759a8 none null
cd4f9b056c74 host host
6fdeb55834bf bridge bridge
8c67bf16fc36 zimbra_bridge bridge


After Dockerizing Zimbra, we get a complete set of email and collaboration tools.


Setting up Zimbra on Docker container ?

1. Download the latest Zimbra Collaboration software. We can download the Open Source edition via:

wget -O opt/zimbra-install/zcs-rhel7.tgz https://files.zimbra.com/downloads/8.7.1_GA/zcs-8.7.1_GA_1670.RHEL7_64.20161025045328.tgz


2. Then we edit Makefile if we want to change the name of the base image to build next. The default name is zimbra-rhel-base;

sed -i ‘s/^IMAGE=.*/IMAGE=new-image-name/g’ Makefile


3. Then we build a Zimbra base image – Which will be the basis for spinning a new container.

Before running ‘sudo make’, we change the hostname on the file setup.sh to match the final hostname.

If we plan on using CentOS 7 Docker image, change directive FROM into Dockerfile match centos:latest ;

sed -i ‘s/^FROM .*$/FROM centos:latest/’ Dockerfile


The default is from rhel7.3 registry.access.redhat.com

Similarly, If we use Local repo: On file opt/zimbra-install/zimbra_install_keystrokes, we replace the second line y with n. To look like below:

$ cat opt/zimbra-install/zimbra_install_keystrokes
y
n
y
y
y
n
y
y
y
y
y
y
y


Then edit zimbra.repo to point to correct base repo URL.

Finally, It is time to create a Zimbra base image:

sudo make


4. Later, after a successful build, spin a container from the new Zimbra base image. Use the below run.sh file:

$ cat run.sh
#!/bin/bash
CONT_NAME=”zimbra”
CONT_DOMAIN=”example.com”
CONT_S_HOSTNAME=”mail”
CONT_L_HOSTNAME=”mail.example.com”
CONT_BRIDGE=”zimbra_bridge”
CONT_IP=”192.168.2.2″
ZIMBRA_PASS=”Password321″
docker run -d –privileged \
–name “${CONT_NAME}” \
–hostname zimbra.example.com \
–net “${CONT_BRIDGE}” \
–ip “${CONT_IP}” \
-e TERM=”xterm” \
-e “container=docker” \
-e PASSWORD=”${ZIMBRA_PASS}” \
-e HOSTNAME=”${CONT_S_HOSTNAME}” \
-e DOMAIN=”${CONT_DOMAIN}” \
-e CONTAINERIP=”${CONT_IP}” \
-e NAME=”${CONT_NAME}” \
-v /var/”${CONT_L_HOSTNAME}”/opt:/opt/zimbra \
-v /etc/localtime:/etc/localtime:ro \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v $(pwd)/zimbra.repo:/etc/yum.repos.d/zimbra.repo \
-p 25:25 -p 80:80 -p 465:465 -p 587:587 \
-p 110:110 -p 143:143 -p 993:993 -p 995:995 \
-p 443:443 -p 8080:8080 -p 8443:8443 \
-p 7071:7071 -p 9071:9071 \
zimbra-rhel-base \
/usr/sbin/init


Also, we change local variables set on top to suit our environment.


5. Before starting Zimbra installation, attach to the container Zimbra interactive terminal and execute /bin/bash:

docker exec -it zimbra /bin/bash


In the meantime, we can just do:

sh ./shell.sh


Once we have active shell access, start automated Zimbra installation:

cd /opt
sh ./start.sh


How to Access Admin Console for Zimbra in Docker ?

After Dockerizing Zimbra, we can run;

start.sh

Eventually, the script will take care of everything. After a few minutes we can access the Admin console using:

Admin Console – https://YOUR_HOST_IP:7071


[Finding it difficult to work with docker containers? Contact us now!]


Conclusion

This article will guide you on the steps to run #Zimbra on #Docker #Container. Docker enables apps to quickly assemble from components.