Running Zimbra on Docker Container
source link: https://computingforgeeks.com/dockerizing-zimbra-on-rhel7-and-centos7/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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.
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.
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
Prereqs
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 192.168.2.0/24
using the command:
# docker network create -d bridge --subnet 192.168.2.0/24 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.3
registry.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
y
n
y
y
y
n
y
y
y
y
y
y
y
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
#!/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, 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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK