- Home
- Installing ONLYOFFICE Mail for Docker on a local server
Installing ONLYOFFICE Mail for Docker on a local server
Introduction
ONLYOFFICE Mail 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 ONLYOFFICE Workspace, ONLYOFFICE Mail 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 ONLYOFFICE Mail Docker version to your machine.
System requirements
- CPUdual core 2 GHz or better
- RAM4 GB or more
- HDDat least 20 GB of free space
- SWAPat least 4 GB, but depends of the host OS. More is better
- OSamd64 Linux distribution with kernel version 3.10 or later
- Additional requirements
- Docker: any version supported by Docker team
Before you start installation
Before you start installation of ONLYOFFICE Mail, you need to link your computer where ONLYOFFICE Mail is going to be installed with the domain selected for the mail server. We recommend that you select a name like mx.yourdomain.com for the A record of your mail server computer. This means that the A record in your Domain Name System (DNS) must point to the IP address of the computer where ONLYOFFICE Mail will be installed and the Pointer (PTR) record on this computer must resolve the computer IP address to a fully-qualified domain name (FQDN) as an opposite to what A record does.
To verify the correctness of the settings for the A record the following command is used:
dig -t A mx.yourdomain.com
If everything is correct you should see the output which contains lines like these among the others:
...;; ANSWER SECTION:
mx.yourdomain.com. IN A {your IP address}...
Instead of {your IP address}
the real IP address of the server will be shown.
The PTR record is checked with another command:
dig -x {your IP address}
It should return the output which contains lines like these among the others:
...;; ANSWER SECTION:{your IP address} IN PTR mx.yourdomain.com....
Once you make sure that all settings are correct, you can proceed to the next steps.
Installing ONLYOFFICE Mail using automatic script command
If you do not want to set everything manually, you can install ONLYOFFICE Mail automatically using our Docker script. You can download the script using our site download page. Or the direct download link can be used, if it is more convenient for you:
wget https://download.onlyoffice.com/install/workspace-install.sh
Once the download is finished, run the following command to install ONLYOFFICE Mail:
bash workspace-install.sh -ics false -ids false -icp false -ims true -md yourdomain.com -es true
Installing ONLYOFFICE Mail manually
If you prefer to have full control of what and how is being installed, you can run the installation in manual mode. To do that follow the steps below.
Installing prerequisites
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.
/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"
For the RPM based operating systems like CentOS:
- Create the
/etc/docker/daemon.json
configuration file with the following contents:{ "dns" : [ "8.8.8.8" ] }
- Restart the Docker service:
sudo systemctl restart docker.service
Before you start the installation you need to create the following folders:
- For MySQL server
sudo mkdir -p "/app/onlyoffice/mysql/conf.d"; sudo mkdir -p "/app/onlyoffice/mysql/data"; sudo mkdir -p "/app/onlyoffice/mysql/initdb";
- And for ONLYOFFICE Mail data and logs
sudo mkdir -p "/app/onlyoffice/MailServer/data/certs"; sudo mkdir -p "/app/onlyoffice/MailServer/logs";
Then create the onlyoffice
network:
sudo docker network create --driver bridge onlyoffice
Installing MySQL
After that you need to create MySQL server Docker container. Create the configuration file:
echo "[mysqld]
sql_mode = 'NO_ENGINE_SUBSTITUTION'
max_connections = 1000
max_allowed_packet = 1048576000
group_concat_max_len = 2048" > /app/onlyoffice/mysql/conf.d/onlyoffice.cnf
Create the SQL script which will generate the users and issue the rights to them. The onlyoffice_user
is required for ONLYOFFICE Community Server, and the mail_admin
is required for ONLYOFFICE Mail in case it is going to be installed:
echo "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'my-secret-pw';
CREATE USER IF NOT EXISTS 'onlyoffice_user'@'%' IDENTIFIED WITH mysql_native_password BY 'onlyoffice_pass';
CREATE USER IF NOT EXISTS 'mail_admin'@'%' IDENTIFIED WITH mysql_native_password BY 'Isadmin123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'onlyoffice_user'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'mail_admin'@'%';
FLUSH PRIVILEGES;" > /app/onlyoffice/mysql/initdb/setup.sql
%
). If you want to limit the access, you can specify hosts which will have access to SQL server.Now you can create MySQL container setting MySQL version to 8.0.29:
sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-mysql-server \
-v /app/onlyoffice/mysql/conf.d:/etc/mysql/conf.d \
-v /app/onlyoffice/mysql/data:/var/lib/mysql \
-v /app/onlyoffice/mysql/initdb:/docker-entrypoint-initdb.d \
-e MYSQL_ROOT_PASSWORD=my-secret-pw \
-e MYSQL_DATABASE=onlyoffice \
mysql:8.0.29
CREATE USER 'mail_admin'@'localhost' IDENTIFIED BY 'Isadmin123';
GRANT ALL PRIVILEGES ON * . * TO 'mail_admin'@'%' IDENTIFIED BY 'Isadmin123';
FLUSH PRIVILEGES;
Installing ONLYOFFICE Mail
After you have everything ready, execute the following command:
sudo docker run --init --net onlyoffice --privileged -i -t -d --restart=always --name onlyoffice-mail-server -p 25:25 -p 143:143 -p 587:587 -p 8081:8081 \
-e MYSQL_SERVER=onlyoffice-mysql-server \
-e MYSQL_SERVER_PORT=3306 \
-e MYSQL_ROOT_USER=root \
-e MYSQL_ROOT_PASSWD=my-secret-pw \
-e MYSQL_SERVER_DB_NAME=onlyoffice_mailserver \
-v /app/onlyoffice/MailServer/data:/var/vmail \
-v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver \
-v /app/onlyoffice/MailServer/logs:/var/log \
-h yourdomain.com \
onlyoffice/mailserver
Where yourdomain.com
is your mail server hostname.
In the command above, the
"yourdomain.com"
parameter must be understood as a service domain for ONLYOFFICE Mail. 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
In this case the mail server will ensure the mail delivery to internal addresses hosted on this server.
Storing data outside containers
All the data are stored in the specially-designated directories, data volumes, at the following location:
/var/log
for ONLYOFFICE Mail 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 located 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 -p 8081:8081 \
-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
Storing the data on the host machine allows you to easily update ONLYOFFICE Mail 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 yourdomain.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
`--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 ONLYOFFICE Mail integrated with ONLYOFFICE Docs
ONLYOFFICE Mail is a part of ONLYOFFICE Workspace that comprises also ONLYOFFICE Docs, ONLYOFFICE Control Panel and ONLYOFFICE Community Server. In case you want to install all of them and integrate with each other, read these instructions.
Alternative ways to install ONLYOFFICE Mail
Alternatively, you can use an automatic installation script to install the whole Workspace at once. For the mail server correct work you need to specify its hostname yourdomain.com
.
STEP 1: Download the installation script file
Execute the following command:
wget https://download.onlyoffice.com/install/workspace-install.sh
STEP 2: Install Workspace
Run the following command to do that:
bash workspace-install.sh -md yourdomain.com