Cannot seem to start Node-RED Docker custom container

I need help with starting my container.
I followed all the steps here https://nodered.org/docs/getting-started/docker to build my image.
However, when I try to start/run the container it exits with the following error in the logs.

Here is my Dockerfile:

FROM nodered/node-red:latest

COPY package.json .
RUN npm install --only=production

# Copy _your_ Node-RED project files into place
COPY settings.js /data/settings.js
COPY flows.json /data/flows.json

# Start the container normally
# CMD [ "npm", "start", "--", "--userDir", "/data"]
CMD ["npm", "start"]

docker logs 75f4b1582b1d

> node-red-project@0.0.1 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" "npm" "start"

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/usr/src/node-red/node_modules/node-red/red.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-project@0.0.1 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" "npm" "start"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-red-project@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/src/node-red/.npm/_logs/2020-05-06T12_11_18_034Z-debug.log

Can someone please help! Why would that module be missing if I am using the official base image. What am I doing wrong?

Thanks!

The page you linked contains a lot of information. Which specific steps did you follow ? You say "to build my image" are you creating your own container ?

Yes I am building my own image using docker build.
I have posted my Dockerfile in the message above.

Thanks!

Have you verified that the path is correct and that node-red is indeed installed there?

1 Like

ok thanks for that hint @afelix. I did and there wasn't any node_module/node-red.
So I figured my package.json file was over-writing the original and that was messing up the install. So I changed my dockerfile to

COPY package.json /data/

However, now it is not installing the sqlite package I need for my flows. I can of-course go in after the container is up and then re-install the "node-red-node-sqlite" package. Something is missing from the instructions as I should be able to simply take my flow and rebuild a image with everything.

These are the new logs -

> node-red-docker@1.0.6 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" "npm" "start"

6 May 12:57:47 - [info]

Welcome to Node-RED
===================

6 May 12:57:47 - [info] Node-RED version: v1.0.6
6 May 12:57:47 - [info] Node.js  version: v10.20.1
6 May 12:57:47 - [info] Linux 4.18.0-193.10.el8.x86_64 x64 LE
6 May 12:57:48 - [info] Loading palette nodes
6 May 12:57:48 - [info] Settings file  : /data/settings.js
6 May 12:57:48 - [info] Context store  : 'memoryOnly' [module=memory]
6 May 12:57:48 - [info] User directory : /data
6 May 12:57:48 - [warn] Projects disabled : editorTheme.projects.enabled=false
6 May 12:57:48 - [info] Flows file     : /data/flows.json
6 May 12:57:48 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

6 May 12:57:48 - [info] Server now running at http://127.0.0.1:1880/
6 May 12:57:48 - [info] Waiting for missing types to be registered:
6 May 12:57:48 - [info]  - sqlitedb
6 May 12:57:48 - [info]  - sqlite
1 Like

I got it working.

Thanks for all your input.

The package.json file didn't have "node-red" as a dependency and therefore npm wasn't installing the package. Once I added "node-red" to the dependency list I was able to get everything working.

Thanks!

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