I’ve been working on  Dockerizing Zimbra on CentOS 7 base image. The hard work has finally yielded fruits and in this post, I’m going to share my Docker Github repository which contains different scripts used.

Dockerizing Zimbra

After Dockerizing Zimbra, you still get a complete set of email and collaboration tools that fits small, medium to large enterprise networks. I’m currently working on autoscaling part and support for automated cluster setups.

Github repository Link

The aim of this is to automate Zimbra installation on Docker. If you encounter any errors be kind to alert me so that I can work on improving.

Dockerizing Zimbra with files in the repo?

Below is the directory tree structure of the files in the repo:

├── Dockerfile
├── etc
│   └── named
│       ├── db.domain
│       └── named.conf
├── Makefile
├── opt
│   ├── start.sh
│   └── zimbra-install
│       ├── zcs-rhel7.tgz
│       └── zimbra_install_keystrokes
├── README.md
├── run.sh
├── setup.sh
├── shell.sh
└── zimbra.repo


Before Dockerizing Zimbra. First, create user-defined docker network for Zimbra. This will enable us to define an forip address the container. On my setup, the bridge created is,zimbra_bridge network subnet is the command:

# docker network create -d bridge --subnet zibra_bridge

Confirm the network is successfully created with:

# docker network ls

NETWORK ID          NAME                DRIVER
f16cc34759a8        none                null                
cd4f9b056c74        host                host                
6fdeb55834bf        bridge              bridge              
8c67bf16fc36        zimbra_bridge       bridge 

Usage and Examples

1. First clone the repo:

git clone https://github.com/jmutai/zimbra-rhel7.git

2. Then cd to zimbra-rhel7 directory

cd zimbra-rhel7

3. Download latest Zimbra Collaboration software. I’ll download Open Source edition here.

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

4. Edit ifMakefile you would like to change the name of the base image to build next. Default name is zimbra-rhel-base

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

5. Build Zimbra base image – Will be the basis for spinning new container.

Before running,sudo make consider changing the hostname on filesetup.sh to match final hostname you’ll use.

If you plan on using CentOS 7 docker image, change directiveFROM in toDockerfile match.centos:latest

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

The default is fromrhel7.3registry.access.redhat.com.

If using Local repo: On fileopt/zimbra-install/zimbra_install_keystrokes, replace the second line y with n. To look like below:

$ cat opt/zimbra-install/zimbra_install_keystrokes

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

It’s now time to create Zimbra base image:

sudo make

6. After a successful build, Spin a container from the new Zimbra base image, see below run.sh file for commands to use:

$ cat run.sh 

docker run -d --privileged \
    --name "${CONT_NAME}" \
    --hostname zimbra.example.com \
    --net "${CONT_BRIDGE}" \
    --ip "${CONT_IP}" \
    -e TERM="xterm" \
    -e "container=docker" \
    -e DOMAIN="${CONT_DOMAIN}" \
    -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 \

Also, change local variables set on top to suite your environment.

If you aren’t using Zimbra local repo remove the line.-v ./zimbra.repo:/etc/yum.repos.d/zimbra.repo It might be a good idea though to set up local repository if playing with docker for the first time; Will save you a lot of time if you screw things up. Visit the link below for how to.

How to Create Local Zimbra Repository

Now spin new Zimbra container:

sh ./run.sh

This will launch a container called inzimbra detached mode. We’re detaching because the default command running is,/usr/sbin/init you cannot attach tty terminal.

7. Before starting Zimbra installation, attach to containerzimbra interactive terminal and execute./bin/bash

docker exec -it zimbra /bin/bash

Alternatively, you can just do:

sh ./shell.sh

Once you have active shell access. Start automated Zimbra installation.

cd /opt
sh ./start.sh 

Accessing Admin Console

After successfully Dockerizing Zimbra. You can run  start.sh script will take care of everything and after a few minutes you can access Admin console using:

Admin Console – https://YOUR_HOST_IP:7071

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here