How to Install Zimbra on Docker Container

Posted by

Docker container that build on this article based on Ubuntu 18.04. The benefit when using container, you can build on any operating system. You can create Docker container on Linux, Mac and Windows. You can also use any Distro Linux (that supported by Docker) to running Docker container 🙂

# Build Docker Images
Please make sure your system already installed Docker 🙂

– Download Dockerfile

cd /srv/
curl -k https://raw.githubusercontent.com/imanudin11/zimbra-docker/master/Dockerfile > Dockerfile

– Build Docker image

docker build -t imanudin:zcsub1804 .

With the above command, you will create Docker image with repository name imanudin and zcsub1804 as Tag. Check Docker images with “docker images” command.

# Create container
Now you can create a container from an image that has been built. Please run below command

docker run -dit --name zcs -h mail.imanudin.net -p 25:25 -p 80:80 -p 443:443 -p 465:465 -p 587:587 -p 993:993 -p 995:995 -p 7071:7071 imanudin:zcsub1804

Now, you have created a Zimbra container. Enter to container

docker exec -it zcs bash

# Configure local DNS
Before installing Zimbra, you should configure local DNS. This DNS needed by Zimbra to resolve MX and A records. I have saved a script to create local DNS automatically. You can see the script on /srv/ folder. So, just run the script and local DNS will automatically be created 🙂

/srv/dns-auto.sh

Below is the example output from dns-auto script

# Download and Install Zimbra
Now, you can install Zimbra. Download, extract and run install.sh script

cd /opt/
wget -c https://files.zimbra.com/downloads/8.8.15_GA/zcs-8.8.15_GA_3869.UBUNTU18_64.20190917004220.tgz
tar -zxvf zcs-8.8.15_GA_3869.UBUNTU18_64.20190917004220.tgz
cd zcs-8.8.15_GA_3869.UBUNTU18_64.20190917004220
./install.sh

Type y/Y if asked :

– Do you agree with the terms of the software license agreement? [N] y
– Use Zimbra’s package repository [Y] y

Type y/Y on all packages except zimbra-dnscache and zimbra-imapd. Zimbra-dnscache not selected because I am using Bind for internal DNS and zimbra-imapd still BETA version

Select the packages to install

Install zimbra-ldap [Y] y
Install zimbra-logger [Y] y
Install zimbra-mta [Y] y
Install zimbra-dnscache [Y] N
Install zimbra-snmp [Y] y
Install zimbra-store [Y] y
Install zimbra-apache [Y] y
Install zimbra-spell [Y] y
Install zimbra-memcached [Y] y
Install zimbra-proxy [Y] y
Install zimbra-drive [Y] y
Install zimbra-imapd (BETA - for evaluation only) [N] N
Install zimbra-chat [Y] y
Checking required space for zimbra-core
Checking space for zimbra-store
Checking required packages for zimbra-store
zimbra-store package check complete.

Installing:
    zimbra-core
    zimbra-ldap
    zimbra-logger
    zimbra-mta
    zimbra-snmp
    zimbra-store
    zimbra-apache
    zimbra-spell
    zimbra-memcached
    zimbra-proxy
    zimbra-drive
    zimbra-patch
    zimbra-mta-patch
    zimbra-proxy-patch
    zimbra-chat

The system will be modified.  Continue? [N] y

Type Y if asked The system will be modified. Continue?

if you get message like below, press enter or type Yes and change domain name

DNS ERROR resolving MX for mail.imanudin.net
It is suggested that the domain name have an MX record configured in DNS
Change domain name? [Yes] Yes
Create domain: [mail.imanudin.net] imanudin.net

Type 6 and then press key enter to change password of admin account. Type again 4 and then press key enter. Insert your password that you want

Main menu

   1) Common Configuration:                                                  
   2) zimbra-ldap:                             Enabled                       
   3) zimbra-logger:                           Enabled                       
   4) zimbra-mta:                              Enabled                       
   5) zimbra-snmp:                             Enabled                       
   6) zimbra-store:                            Enabled                       
        +Create Admin User:                    yes                           
        +Admin user to create:                 admin@imanudin.net            
******* +Admin Password                        UNSET                         
        +Anti-virus quarantine user:           virus-quarantine.7nbg3upe@imanudin.net
     
... skip ...                      

Address unconfigured (**) items  (? - help) 6

Store configuration

   1) Status:                                  Enabled                       
   2) Create Admin User:                       yes                           
   3) Admin user to create:                    admin@imanudin.net            
** 4) Admin Password                           UNSET                         
   5) Anti-virus quarantine user:              virus-quarantine.7nbg3upe@imanudin.net

... skip ...

Select, or 'r' for previous menu [r] 4

Password for admin@imanudin.net (min 6 characters): [9M1CRucQ] v3rysecre7p4ssword

After insert password, Select, or ‘r’ for the previous menu. If all has been configured, apply configuration and wait until Zimbra install finished

*** CONFIGURATION COMPLETE - press 'a' to apply
Select from menu, or press 'a' to apply config (? - help) a
Save configuration data to a file? [Yes] Yes
Save config in file: [/opt/zimbra/config.1450] press key enter
Saving config in /opt/zimbra/config.1450...done.
The system will be modified - continue? [No] Yes
Operations logged to /tmp/zmsetup.20191003-082624.log

Type Yes if asked Notify Zimbra of your installation? and if has been appeared Configuration complete – press return to exit, your zimbra installation has been finished. Check Zimbra status with this command su – zimbra -c “zmcontrol status” and make sure all service running well. You can access webmail via browser at url https://ZimbraServer

You have the option of notifying Zimbra of your installation.
This helps us to track the uptake of the Zimbra Collaboration Server.
The only information that will be transmitted is:
	The VERSION of zcs installed (8.8.15_GA_3869_UBUNTU18_64)
	The ADMIN EMAIL ADDRESS created (admin@imanudin.net)

Notify Zimbra of your installation? [Yes] Yes
Notification skipped
Checking if the NG started running...done. 
Setting up zimbra crontab...done.

Moving /tmp/zmsetup.20191003-082624.log to /opt/zimbra/log

Configuration complete - press return to exit 

# Add service Zimbra to /services.sh
For make sure Zimbra service auto start/restart when start Docker container, please add Zimbra service to script /services.sh.

vi /services.sh

and add this line on the bottom

/etc/init.d/zimbra restart

So, the lines on /services.sh like below

cat /etc/resolv.conf > /tmp/resolv.ori
echo "nameserver 127.0.0.1" > /tmp/resolv.add
cat /tmp/resolv.add /tmp/resolv.ori > /etc/resolv.conf
/etc/init.d/bind9 restart
/etc/init.d/rsyslog restart
/etc/init.d/zimbra restart

Good luck and hopefully useful 🙂

9 comments

  1. While install zimbra ….i got this error
    Warning: apt-key output should not be parsed (stdout is not a terminal)
    Importing Zimbra GPG key
    ERROR: Unable to retrive Zimbra GPG key for package validation
    Please fix system to allow normal package installation before proceeding

  2. apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 9BE6ED79 Executing: /tmp/apt-key-gpghome.3FiaRPtE69/gpg.1.sh –keyserver keyserver.ubuntu.com –recv-keys 9BE6ED79
    gpg: keyserver receive failed: Invalid argument

    I was try some other way as per zimbra instruction same error coming.

    1. Hello,
      Maybe keyserver.ubuntu.com cannot resolve by your system. Please try this command

      host -t A keyserver.ubuntu.com | awk '{print $4,$1}' >> /etc/hosts
      

      Or you can add manual the records on /etc/hosts

      162.213.33.8 keyserver.ubuntu.com
      162.213.33.9 keyserver.ubuntu.com
      

      Then install again

  3. Great tutorial, can I suggest using volumes to get persist data when docker daemon restart o even the server restart? also this is good for backup that volumes and configuration of Zimbra.

    Thanks for you knowledge.

    Best regards
    Ignacio

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.