Cloud Computing Insider Awards 2022: Vote for ONLYOFFICE

Docker - relation between default.json and local.json

I have a question about OnlyOffice and Docker.

The general documentation states that changes should only be done in the local.json file while the default.json is the base configuration.

But when I try to set my settings in a local.json file and bind this file to the docker container as a local volume:

    image: onlyoffice/documentserver
    container_name: onlyoffice-app
      - 80
      - "80:80"
      - ./configuration/onlyoffice/local.json:/etc/onlyoffice/documentserver/local.json

I see the following exceptions during startup phase:

onlyoffice-app     | internal/fs/utils.js:314
onlyoffice-app     |     throw err;
onlyoffice-app     |     ^
onlyoffice-app     | 
onlyoffice-app     | Error: EBUSY: resource busy or locked, rename '/etc/onlyoffice/documentserver/.local.json-json-144-1657542900908.tmp' -> '/etc/onlyoffice/documentserver/local.json'
onlyoffice-app     |     at Object.renameSync (fs.js:794:3)
onlyoffice-app     |     at WriteStream.<anonymous> (/snapshot/node_modules/json/lib/json.js)
onlyoffice-app     |     at WriteStream.emit (events.js:412:35)
onlyoffice-app     |     at internal/fs/streams.js:340:12
onlyoffice-app     |     at FSReqCallback.oncomplete (fs.js:180:23) {
onlyoffice-app     |   errno: -16,
onlyoffice-app     |   syscall: 'rename',
onlyoffice-app     |   code: 'EBUSY',
onlyoffice-app     |   path: '/etc/onlyoffice/documentserver/.local.json-json-144-1657542900908.tmp',
onlyoffice-app     |   dest: '/etc/onlyoffice/documentserver/local.json'
onlyoffice-app     | }

This happens even if I grant access to all users (chmod 777).

If I change the default.json file directly and bind this file as a local volume, all works great without error messages during startup.

So my question is: how is the correct way to customize configuration in case running OnlyOffice in Docker?

Hello @rsoika
Local.json file is generated when container is started. So there’s no way to map it on the host.
In general, mapping these config files to the host is not a good idea. Sometimes we change these configs due to update process. This way you can break your installation with your old customized config files due to the update process.

I believe the best solution is using environment variables:
For example, -e JWT_ENABLED=true -e JWT_SECRET=mysecret

Thanks for your feedback. Yes I think that setting environment variables is the best way. I was not aware of the helpcenter page.
For example I already set the variable WOPI_ENABLED=true.

This variable is mapped to

  "wopi": {
    "enable": true

which is surprising as you would guess that this JSON setting maps to a variable like WOPI_ENABLE.

For example: what if I want to set wopi: {host:....}? I already tried setting WOPI_HOST but this did not work - now I understand that this seems not to be a supported configuration parameter.

Why do you not use a kind of parser, checking all environment variables and if it matches a JSON structure from the default.json than overtake this into the local.json. This would be super cool as this gives me more control about the configuration details running OnlyOffice in docker-compose or Kubernetes?

(you know our other discussion about the WOPI setup in Docker-Compose)

Probably this is a good idea. But we are not ready to start this project at the moment.
Sorry for inconvenience.

Hi @Alexandre - no problem if this feature is not implemented.
But to come back to my initial question: This means the only way to configure OnlyOffice running in a Docker Container is to overwrite the default.json file and map it via a local volume. You did not recommand it in your first answer, but there is no other way - right?

Yes, we do not recommend it. You have to keep in mind that config file can be changed due to update process.
So, for container deploying you can use environment variables.
But there’s a workaround solution for parameters which cannot be set via environment.
As we know default.json file can be overwritten during an update and the changes will be lost. If you wish to avoid that, you can create a file named local-production-linux.json in the same folder and paste the required parameters from default.json there. It will have priority over any other configuration files. Note that the structure of default.json needs to be strictly preserved, but you only need to paste the parameters you need, not the full contents of it.
Since you’re using Docker, you will also need to mount the file from the host machine so that any new container could use it.

1 Like

Ok, thanks for your reply again. But when I use Docker in a productive Environment I would not take the :latest image but a specific version. And so there is not need to worry about updates because this will always launch the same version. So I can use the corresponding default.json config and overwrite it to my needs. With the separate file brings no advantage at all.

Each new version contains new features and fixes for known bugs. For example, if you face any issue, I will ask you to update DS to the latest version first. It’s better to troubleshoot situation on the actual version.

Ok now I understand - thanks again!

1 Like