Where is the root directory of node-red in the docker image?

Hello,

I'm trying to install a package to my image I'm building. I've been searching around on the base image (nodered/node-red) and it seems to be /usr/src/node-red/?

When installing extensions they state I have to be in the root directory (example: node-red-contrib-elasticsearch-jd (node) - Node-RED).

My current Dockerfile:

FROM nodered/node-red
WORKDIR /usr/src/node-red/
RUN npm install node-red-contrib-elasticsearch-jd

But when I run the container I don't see any of the new features. So I installed it to the wrong directory? Could anyone point me to the root directory of the node-red install on the docker hub image?

You generally don't install anything to the node-red root. You install packages containing nodes to the userDir folder. That defaults to ~/.node-red on a "standard" install. For the standard Docker build, that folder is /data/ as stated in the docs Running under Docker : Node-RED (nodered.org).

Those same docs show you how to get into your docker instance as a terminal.

Further down that same page, it tells you how you can have your own custom /data/ folder which is what you are wanting to do I think.

1 Like

Thank you for reply. I mounted /data on my host machine and was from there able to install the packages needed. Simply.
I don't really need a custom image any longer :slight_smile:

1 Like

I feel this is my case as well. Could you please explain that using words for neewbie? I know that using Docker some user data is kept inside container folder and this one in mapped to the external (external to the container) folder /node-red/data right? So if i want to install new packages i need to run
nmp install command form /data folder - so not from inside of the container but using Pi terminal, right?

Yes, i was reading the above mentioned docs, however, Linux, Docker is still kinda magic for me, sorry.

The idea of (docker) containers is that they only "contain" the program - no user data - consider them read-only.

User data should always be outside the container (and thus) mapped to the host. The mapping is decided upon creation of the container by means of the -v option (-volume), see documentation (bind mount)

-v <host path>:<path in container>

Use the node-red UI to install packages and they will be installed in <host path>/node_modules

Thank you bakman2 for clarification. It is now easy. Well almost. I know where to install modules so Node-RED UI -> user settings -> Palette -> install -> here i found the one i need, confirmed intallation and:

-----------------------------------------------------------
2021-12-22T06:09:33.828Z Install : node-red-contrib-ui-svg 2.3.1

2021-12-22T06:09:37.026Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-ui-svg@2.3.1

and after some minute:


-----------------------------------------------------------
2021-12-22T06:09:33.828Z Install : node-red-contrib-ui-svg 2.3.1

2021-12-22T06:09:37.026Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-ui-svg@2.3.1
2021-12-22T06:10:54.178Z [err] npm
2021-12-22T06:10:54.178Z [err]  ERR! code ECONNRESET
2021-12-22T06:10:54.179Z [err] npm
2021-12-22T06:10:54.179Z [err]  ERR!
2021-12-22T06:10:54.179Z [err]  errno
2021-12-22T06:10:54.179Z [err]  ECONNRESET
2021-12-22T06:10:54.185Z [err] npm
2021-12-22T06:10:54.185Z [err]  ERR! network
2021-12-22T06:10:54.185Z [err]  request to https://registry.npmjs.org/node-red-contrib-ui-svg failed, reason: read ECONNRESET
2021-12-22T06:10:54.185Z [err] npm 
2021-12-22T06:10:54.185Z [err] ERR! 
2021-12-22T06:10:54.185Z [err] network This is a problem related to network connectivity.
2021-12-22T06:10:54.185Z [err] npm 
2021-12-22T06:10:54.185Z [err] ERR! 
2021-12-22T06:10:54.185Z [err] network
2021-12-22T06:10:54.185Z [err]  In most cases you are behind a proxy or have bad network settings.
2021-12-22T06:10:54.185Z [err] npm
2021-12-22T06:10:54.185Z [err]  ERR!
2021-12-22T06:10:54.186Z [err]  network
2021-12-22T06:10:54.186Z [err]  
2021-12-22T06:10:54.186Z [err] npm
2021-12-22T06:10:54.186Z [err]  ERR!
2021-12-22T06:10:54.186Z [err]  network
2021-12-22T06:10:54.186Z [err]  If you are behind a proxy, please make sure that the
2021-12-22T06:10:54.186Z [err] npm 
2021-12-22T06:10:54.186Z [err] ERR! 
2021-12-22T06:10:54.186Z [err] network 'proxy' config is set properly.  See: 'npm help config'
2021-12-22T06:10:54.238Z [err] 
2021-12-22T06:10:54.238Z [err] npm ERR!
2021-12-22T06:10:54.238Z [err]  A complete log of this run can be found in:
2021-12-22T06:10:54.238Z [err] npm ERR!
2021-12-22T06:10:54.238Z [err]      /data/.npm/_logs/2021-12-22T06_10_54_188Z-debug.log
2021-12-22T06:10:54.249Z rc=1

I'm working on offshore installation and "IT policy", "cyber security" rules here are rigid and no one will allow to change any proxy settings etc...

I found option to "upload module tgz file" but how can i find tgz files for:
node-red-contrib-ui-svg
node-red-contrib-drawsvg
and more...
Thanks!

I am not sure how one can configure a proxy in docker, maybe as an environment variable (eg: -e http_proxy=http://myproxy.com:8080 when creating the container), perhaps @dceejay has some guidance.

You can pass on environment variables on the docker command line with the -e option.

And I've answered the tgz question on the other thread

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