Node-red docker settings.js

Hi, I am using node-red in docker container. Starting it up with --settings argument to pass on a custom settings file.
The container starts up fine but after a while it goes unhealthy and reports:

internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module '/data/settings.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/healthcheck.js:3:16) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)

as I used --settings argument the settings.js file is not in the standard /data directory. However something seem to look for it still. Any ideas on how to run with custom settings.js and don't get this message?

Welcome.

Which container are you using, and where did you find the "--settings" argument ?

container image: nodered/node-red:1.0.6
the --settings argument as described here https://nodered.org/docs/user-guide/runtime/settings-file

I think I have it sorted now though. I simply use a volume for /data and another for /data/settings.js

In order to help you understand what the problem was, so you don't hit it again, I presume you were using the --settings argument in the startup command for node-red in the container. If so and if you gave it a path to somewhere on the host file system then that wouldn't work as the container doesn't have direct access to the host file system. That is what Volumes are for, for mapping files/folders on the host file system into the container.

that is understood. I had mapped the settings file to /etc/node-red-settings/settings.js into the docker container. It started up fine but however after a while I got the message that /data/settings.js is missing.

To me that sounds like something is still looking for /data/settings.js even though I gave another path for settings.js through --settings argument.

the healthcheck.js does have hardcoded check for /data/settings.js

It is part of node-red docker release: https://github.com/node-red/node-red-docker/blob/master/.docker/healthcheck.js

So can I define this to docker-compose.yml file as following

services:

  nodered:
    restart: always
    image: nodered/node-red:latest
    command:
      - "--settings /path/to/settings.js"
    ...

it's possible to do it. It loads correct settings. However the healthcheck.js for docker does not like it. It looks for /data/settings.js if that file does not exist it reports unhealthy.

1 Like

Thanks. So it should be fixed somehow :slight_smile:

I think it would be easy fixed with dockers environment variables, but never done PR :thinking:

1 Like

You can always ask it not to run the healthcheck

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.