Thursday, December 26, 2024
Google search engine
HomeUncategorisedHow To Run ONLYOFFICE Docs as a Docker Container

How To Run ONLYOFFICE Docs as a Docker Container

In this guide, you will learn how to install and set up ONLYOFFICE Docs using a Docker container. Following the steps described below, you will teach yourself how to install the latest version of Docker and deploy a collaborative office suite for text documents, spreadsheets and presentations with ONLYOFFICE Docs.

What is ONLYOFFICE Docs?

ONLYOFFICE Docs is an open-source office suite that makes it possible to create a collaborative environment by bringing document editing capabilities to a wide range of file-sharing solutions and document management systems, including Nextcloud, Alfresco, ownCloud, Confluence, Liferay, Nuxeo, ownCloud, SharePoint, ONLYOFFICE Workspace, etc.

ONLYOFFICE Docs comes with the following features:

  • Collaborative editors for text documents, spreadsheets, and presentations of any kind.
  • Real-time co-editing (two co-editing modes, track changes, autosave, version history, comments and user mentions, communication via the built-in chat).
  • Various access permissions (full access, review, form filling, commenting, viewing).
  • Complete compatibility with Word, Excel and PowerPoint files;
  • Support for other popular formats though conversion: DOC, TXT, ODT, RTF, ODP, EPUB, ODS, XLS, CSV, HTML.
  • Third-party plugins and JavaScript macros (YouTube videos, Google Translate, Zotero, Mendeley, Photo Editor, Telegram, Word counter, etc.).
  • Enhanced security (JSON Web Token, configurable cache lifetime, HTTPS, etc.).

Hardware and software requirements

Before you start the installation process, please make sure that your hardware meets the following requirements:

  • CPU: dual-core with 2 GHz or higher;
  • RAM: no less than 4 GB;
  • Swap space: at least 2 GB;
  • HDD: at least 2 GB of free space;
  • Docker: v1.9.0 or newer.

Step 1 – Install Docker

To install ONLYOFFICE Docs, you need Docker to be installed on your machine. If you want to install and configure the latest version of Docker, you can refer to the following guide:

Step 2 – Install ONLYOFFICE Docs

When Docker is successfully installed on your machine, run it and enter this command to install ONLYOFFICE Docs:

sudo docker run -i -t -d -p 80:80 --restart=always onlyoffice/documentserver

That’s it. You now have a fully working office suite deployed on your machine. But read the instructions below if you want to fine-tune and make it more secure.

Please note that ONLYOFFICE Docs uses port 80 for incoming connections. To change the default port, run the following command:

sudo docker run -i -t -d -p <PORT_NUMBER>:80 --restart=always onlyoffice/documentserver

In this command, <PORT_NUMBER> is the number of the port you want ONLYOFFICE Docs to use for incoming connections.

Step 3 – Make sure your data is stored outside the Docker container

We don’t recommend skipping this step because storing your data outside the Docker container on your machine allows you to easily update ONLYOFFICE Docs in the future without losing your data.

All your data (logs, certificates, file cache, etc.) is stored in special directories, also known as data volumes, in the following locations:

  • /var/log/onlyoffice — ONLYOFFICE Docs logs;
  • /var/www/onlyoffice/Data — certificates; 
  • /var/lib/onlyoffice — file cache;
  • /var/lib/postgresql — your database.

To access your data stored outside the Docker container, you need to mount these volumes by adding the -v option in the docker run command:

sudo docker run -i -t -d -p 80:80 --restart=always \
    -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice  \
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data  \
    -v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
    -v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql  onlyoffice/documentserver

If you mount the folders that haven’t been created yet, they will be created in any case but your access will be limited. You will have to change their access rights manually.

Step 4 – Run ONLYOFFICE Docs using HTTPS

To run ONLYOFFICE Docs through the HTTPS protocol, enter this:

sudo docker run -i -t -d -p 443:443 --restart=always \
-v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data  onlyoffice/documentserver

If you want to prevent unauthorized access, you can also use an SSL certificate. To do so, you just need two things:

  • Private key (.key)
  • SSL certificate (.crt)

That means that you need to create and install the following files:

  • /app/onlyoffice/DocumentServer/data/certs/onlyoffice.key
  • /app/onlyoffice/DocumentServer/data/certs/onlyoffice.crt

If you have a certificate issued by a certification authority (for example, Let’s Encrypt), these files are provided by the CA. If you prefer self-signed certificates, you need to generate these files on your own. 

Switching ONLYOFFICE Docs to HTTPS using certbot

The preferred way to run ONLYOFFICE Docs through the HTTPS protocol is to get a Let’s Encrypt SSL certificate using certbot. Run ONLYOFFICE Docs specifying ports 80 and 443 and entering your own values for the variables below:

sudo docker run -i -t -d -p 80:80 -p 443:443 \
    -e LETS_ENCRYPT_DOMAIN=yourdomain.com -e [email protected]  onlyoffice/documentserver
  • LETS_ENCRYPT_DOMAIN – the domain name used for your SSL certificate.
  • LETS_ENCRYPT_MAIL – the email address that you used while registering.

The Let’s Encrypt certificate will be automatically generated and installed on your machine. Your ONLYOFFICE Docs instance will be available at https://yourdomain.com.

Congratulations! You have successfully walked through the configuration process. You can now run ONLYOFFICE Docs as a Docker container and edit text documents, spreadsheets and presentations online.

There are some additional configuration parameters that can be found here

Step 5 – Test ONLYOFFICE Docs 

Additionally, you can test the editors’ functionality before integrating ONLYOFFICE Docs with a third-party file-sharing solution. To do so, you need to run the test example, a simple document management system.

By default, the test example is disabled, but you can see the instructions on how to enable it on your start screen. Just go to https://yourdomain.com/welcome and follow the instructions.

The test example will become available at https://yourdomain.com/example.

Using the test example, you can check if ONLYOFFICE Docs work correctly by uploading and editing local files or creating new ones (DOCX, XLSX and PPTX). 

More articles on Docker:

RELATED ARTICLES

Most Popular

Recent Comments