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.
Docker specifies Google DNS servers by default. If your
ONLYOFFICE Groups 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"
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
Please note, that the above script will set permissions to access SQL server from any domains (%
). 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
If you want to use an external database, you need to set up it (namely, add a user):
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.
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 ONLYOFFICE Mail is installed).
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
We recommend
We strongly recommend that you store the data outside the Docker containers on the host machine as it allows you to easily update ONLYOFFICE Mail once the new version is released without losing your data.
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
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 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
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
.