Articles with the tag:
Close
Changelog
Close
Help Center
Mail Server for Docker

Installing Mail Server for Docker on a local server

Mail Serverv.1.6 Mail Server changelog

Version 1.6.20

Release date: 12/05/2016

Connection Settings

  • Added page to the Settings for the integration of Community Server (Windows version) with Mail Server.

Installation Script

  • Fixed the error shown if the mail domain is not specified, now Mail Server will not be installed if this is the case.

Version 1.6.7

Release date: 06/22/2016

Refactoring

  • Removed version from the iRedMail folder;
  • iRedMail completed with commits from v.0.9.2;
  • Deleted unused packages from iRedMail;
  • Added the SpamAssassin setup with initial bayes_tokens.

Runtime

  • Fixed the incorrect MySQL server name in the config;
  • Fixed the issue with the config section duplication when starting the Docker container;
  • Fixed the issue with sending mail to a group/alias address;
  • Fixed the startup API issue.

Logging

  • Fixed logging during the installation.

Networking

  • Fixed the fail2ban and iptables issue when starting Docker in a network mode;
  • Fixed the issue with Mail Server on an external physical server.

Version 1.6.0

Release date: 03/09/2016

Settings

  • Redesigned Mail Server settings page.

Version 1.5.0

Release date: 04/20/2015

Mail Server

  • Mail Server for Docker first release.

Introduction

Mail Server is a full-featured mail server solution developed on the base of the iRedMail package, containing the following components: Postfix, Dovecot, SpamAssassin, ClamAV, OpenDKIM, Fail2ban.

Integrated with Community Server, Mail Server allows you to:

  • connect your own domain name;
  • create mailboxes;
  • add aliases for each mailbox;
  • create mailbox groups.

This guide will show you how to install Mail Server Docker version to your machine.

System requirements

  • CPU
    dual-core 2 GHz or better
  • RAM
    4 GB or more
  • HDD
    at least 2 GB of free space
  • Additional Requirements
    at least 2 GB of swap
  • OS
    amd64 Linux distribution with kernel version 3.10 or later
  • Additional Requirements
    • Docker: version 1.10 or later

Installing Mail Server

You need the latest Docker version installed. If you do not have it, please see the Installation section on Docker website to learn how to get it.
Docker specifies Google DNS servers by default. If your Mail Server is not going to have access to the Internet, we recommend that you change the default Docker DNS address to the address of your local DNS server. To do that go to the /etc/default/docker file and change the IP address in the following line to the IP address of a DNS server in your local network:
docker_OPTS="--dns 8.8.8.8"

After you have Docker installed, run it and execute the following command:

sudo docker run --privileged -i -t -d -p 25:25 -p 143:143 -p 587:587 \
-h hostname.com onlyoffice/mailserver

Where hostname.com is your mail server hostname.

Your domain that will be used for maintaining correspondence must be valid and configured for this machine (i.e. it should have the appropriate A record in the DNS settings that points your domain name to the IP address of the machine where Mail Server is installed).
In the command above, the "hostname.com" parameter must be understood as a service domain for Mail Server. It is usually specified in the MX record of the domain that will be used for maintaining correspondence. As a rule, the "hostname.com" looks like mx1.onlyoffice.com

In this case the mail server will ensure the mail delivery to internal addresses hosted on this server.

Automatic restart

To make Docker automatically restart Mail Server containers on reboot, please use the --restart=always parameter in the docker run command:

sudo docker run --privileged -i -t -d -p 25:25 -p 143:143 -p 587:587 \
-h hostname.com --restart=always onlyoffice/mailserver

Storing data outside containers

All the data are stored in the specially-designated directories, data volumes, at the following location:

  • /var/log for Mail Server logs
  • /var/lib/mysql for MySQL database data
  • /var/vmail for mail storage
  • /etc/pki/tls/mailserver for certificates

To get access to your data from outside the container, you need to mount the volumes. It can be done by specifying the -v option in the docker run command.

sudo docker run --privileged -i -t -d -p 25:25 -p 143:143 -p 587:587 \
        -v /app/onlyoffice/MailServer/logs:/var/log  \
        -v /app/onlyoffice/MailServer/mysql:/var/lib/mysql  \
        -v /app/onlyoffice/MailServer/data:/var/vmail  \
        -v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver -h yourdomain.com onlyoffice/mailserver
Please note, that in case you are trying to mount the folders which are not yet created, these folders will be created but the access to them will be limited. You will need to change their access rights manually.

Storing the data on the host machine allows you to easily update Mail Server once the new version is released without losing your data.

Configuring Docker image

To ensure the mail delivery to internal addresses as well as addresses of external servers you need to get your own domain name and configure a DNS server.

The following DNS records are required:

  • A record (used to point a domain to the IP address of the host where this docker image is deployed).
  • Pointer (PTR) record or a reverse DNS record (used to map a network interface (IP) to a hostname).
sudo docker run --privileged -i -t -d -p 25:25 -p 143:143 -p 587:587 \
-v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver -h yourdomain.com onlyoffice/mailserver

Where hostname.com is your mail server hostname.

Installing the SSL certificates

The self-signed certificates for your domain will be created by default while running the docker container. If you want to use CA sertified certificates, you will need to rename them and copy into the /app/onlyoffice/MailServer/data/certs directory before running the image. The following files are required:

  • /app/onlyoffice/MailServer/data/certs/mail.onlyoffice.key
  • /app/onlyoffice/MailServer/data/certs/mail.onlyoffice.crt
  • /app/onlyoffice/MailServer/data/certs/mail.onlyoffice.ca-bundle

You can copy the SSL certificates into the /app/onlyoffice/MailServer/data/certs directory after running the image. But in this case you will need to restart the docker container.

Available configuration parameters

Please refer the docker run command options for the `--env-file` flag where you can specify all required environment variables in a single file. This will save you from writing a potentially long docker run command.

Below is the complete list of parameters that can be set using environment variables.

  • STORAGE_BASE_DIR: The path to the mail store. Defaults to /var/vmail.
  • FIRST_DOMAIN: The first virtual domain, where the postmaster address will be hosted. This domain should not coincide with the primary mail server domain. Defaults to mailserver.onlyoffice.com.
  • DOMAIN_ADMIN_PASSWD: The postmaster password. The default postmaster address is postmaster@mailserver.onlyoffice.com.

Installing Mail Server integrated with Document and Mail Servers

Mail Server is a part of ONLYOFFICE Community Edition that comprises also Document Server and Community Server. To install them, follow these easy steps:

STEP 1: Create the 'onlyoffice' network
docker network create --driver bridge onlyoffice

After that launch the containers on it using the 'docker run --net onlyoffice' option.

STEP 2: Install Document Server
sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-document-server \
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \
    -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \
    onlyoffice/documentserver
STEP 3: Install Mail Server
sudo docker run --net onlyoffice --privileged -i -t -d --restart=always --name onlyoffice-mail-server \
    -p 25:25 -p 143:143 -p 587:587 \
    -v /app/onlyoffice/MailServer/data:/var/vmail \
    -v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver \
    -v /app/onlyoffice/MailServer/logs:/var/log \
    -v /app/onlyoffice/MailServer/mysql:/var/lib/mysql \
    -h yourdomain.com \
    onlyoffice/mailserver

Where yourdomain.com is your mail server hostname.

Your domain that will be used for maintaining correspondence must be valid and configured for this machine (i.e. it should have the appropriate A record in the DNS settings that points your domain name to the IP address of the machine where Mail Server is installed).
In the command above, the "yourdomain.com" parameter must be understood as a service domain for Mail Server. It is usually specified in the MX record of the domain that will be used for maintaining correspondence. As a rule, the "yourdomain.com" looks like mx1.onlyoffice.com
STEP 4: Install Community Server
sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-community-server \
    -p 80:80 -p 5222:5222 -p 443:443 \
    -v /app/onlyoffice/CommunityServer/data:/var/www/onlyoffice/Data \
    -v /app/onlyoffice/CommunityServer/mysql:/var/lib/mysql \
    -v /app/onlyoffice/CommunityServer/logs:/var/log/onlyoffice \
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/DocumentServerData \
    -e DOCUMENT_SERVER_PORT_80_TCP_ADDR=onlyoffice-document-server \
    -e MAIL_SERVER_DB_HOST=onlyoffice-mail-server \
    onlyoffice/communityserver

Alternatively, you can use docker-compose to install the whole ONLYOFFICE Community Edition at once. For the mail server correct work you need to specify its hostname 'yourdomain.com'.

STEP 1: Download the installation script file

Assuming you have docker-compose installed, execute the following command:

wget http://download.onlyoffice.com/install/opensource-install.sh
STEP 2: Install ONLYOFFICE Community Edition

Run the following command to do that:

bash opensource-install.sh -md yourdomain.com
Download Host on your own server Available for Docker,
Windows, Linux and virtual machines
You Might Also Like This:
Close