Install extra node in docker


pi@odroidn2:~$ sudo docker volume ls
[sudo] wachtwoord voor pi:
DRIVER    VOLUME NAME
local     grafana_grafana_storage
local     influxdb_influxdb_data
local     nodered_node-red-data
local     zwave-config
pi@odroidn2:~$

And:

DRIVER    VOLUME NAME
local     grafana_grafana_storage
local     influxdb_influxdb_data
local     nodered_node-red-data
local     zwave-config
pi@odroidn2:~$ ^C
pi@odroidn2:~$ sudo docker volume inspect nodered_node-red-data
[
    {
        "CreatedAt": "2024-06-01T18:13:40+02:00",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "nodered",
            "com.docker.compose.version": "1.29.2",
            "com.docker.compose.volume": "node-red-data"
        },
        "Mountpoint": "/var/lib/docker/volumes/nodered_node-red-data/_data",
        "Name": "nodered_node-red-data",
        "Options": null,
        "Scope": "local"
    }
]
pi@odroidn2:~$

on your odroid

sudo -s (be careful now, since you are acting as root)

cd /var/lib/docker/volumes/nodered_node-red-data/_data

What is the output of ls?

Why not just use the node-red editor > manage palette > install the node.
It will install it at the proper place.

1 Like

Well. I assumed, Dylantje did so and provided log is from nodered's editor? Good point @bakman2


pi@odroidn2:~$ sudo -s
[sudo] wachtwoord voor pi:
root@odroidn2:/home/pi# cd /var/lib/docker/volumes/nodered_node-red-data/_data
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data#
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data#
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data#

Perhaps to this reason:

-----------------------------------------------------------
2024-12-28T11:14:02.067Z Install : node-red-contrib-tasmota 1.0.0

2024-12-28T11:14:01.410Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --omit=dev --engine-strict node-red-contrib-tasmota@1.0.0
2024-12-28T11:14:04.517Z [err] npm error code EACCES
2024-12-28T11:14:04.518Z [err] npm error syscall open
2024-12-28T11:14:04.518Z [err] npm error path /data/.npm/_cacache/tmp/e6dee464
2024-12-28T11:14:04.518Z [err] npm error errno EACCES
2024-12-28T11:14:04.518Z [err] npm error
2024-12-28T11:14:04.518Z [err] npm error Your cache folder contains root-owned files, due to a bug in
2024-12-28T11:14:04.518Z [err] npm error previous versions of npm which has since been addressed.
2024-12-28T11:14:04.518Z [err] npm error
2024-12-28T11:14:04.518Z [err] npm error To permanently fix this problem, please run:
2024-12-28T11:14:04.518Z [err] npm error   sudo chown -R 1000:1000 "/data/.npm"
2024-12-28T11:14:04.522Z [err] npm error A complete log of this run can be found in: /data/.npm/_logs/2024-12-28T11_14_01_674Z-debug-0.log
2024-12-28T11:14:04.543Z rc=1

What is the output of ls inside /var/lib/docker/volumes/nodered_node-red-data/_data. Is it really empty? Is node-red running?

root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data# ls
flows_cred.json  flows.json  lib  node_modules  package.json  package-lock.json  settings.js
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data#

Running like a dear :slight_smile:

Add:

      - PGID=1000
      - PUID=1000

to the environment section and restart the container. then try to reinstall using via the browser.

OK ... my bad :slight_smile: ... what does ls -la show ... we are missing .npm here :slight_smile:


root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data# ^C
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data# ls -la
totaal 1988
drwxrwxr-x   5 pi   root   4096 28 dec 11:09 .
drwx-----x   3 root root   4096  1 jun  2024 ..
-rw-r--r--   1 pi   pi    50815 27 dec 19:53 .config.nodes.json
-rw-r--r--   1 pi   pi    50815 27 dec 19:53 .config.nodes.json.backup
-rw-r--r--   1 pi   pi      133  1 jun  2024 .config.runtime.json
-rw-r--r--   1 pi   pi       95  1 jun  2024 .config.runtime.json.backup
-rw-r--r--   1 pi   pi      701 27 dec 19:53 .config.users.json
-rw-r--r--   1 pi   pi      701 27 dec 19:53 .config.users.json.backup
-rw-r--r--   1 pi   pi      211 27 dec 16:53 flows_cred.json
-rw-r--r--   1 pi   pi      135 27 dec 16:53 .flows_cred.json.backup
-rw-r--r--   1 pi   pi   839457 28 dec 11:09 flows.json
-rw-r--r--   1 pi   pi   843399 28 dec 11:09 .flows.json.backup
drwxr-xr-x   3 pi   pi     4096  1 jun  2024 lib
drwxr-xr-x 177 pi   pi     4096  1 jun  2024 node_modules
drwxr-xr-x   4 pi   pi     4096  1 jun  2024 .npm
-rw-r--r--   1 pi   pi     1067 27 mrt  2024 package.json
-rw-r--r--   1 root root 169584 27 mrt  2024 package-lock.json
-rw-r--r--   1 pi   pi    22614 27 jul  2023 settings.js
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data#

thanks.. only 2 gys that help me... Is this going well?

What and where doe add tis?

We should be almost there. Inside the folder /var/lib/docker/volumes/nodered_node-red-data/_data run chown -R 1000:1000 ".npm" -> still as root


root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data# chown -R 1000:1000 ".npm"
root@odroidn2:/var/lib/docker/volumes/nodered_node-red-data/_data#

And then?

Try the install tasmota

2024-12-28T11:26:44.843Z Install : node-red-contrib-tasmota 1.0.0

2024-12-28T11:26:44.162Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --omit=dev --engine-strict node-red-contrib-tasmota@1.0.0
2024-12-28T11:26:47.750Z [err] npm error code EACCES
2024-12-28T11:26:47.750Z [err] npm error syscall open
2024-12-28T11:26:47.750Z [err] npm error path /data/package-lock.json
2024-12-28T11:26:47.751Z [err] npm error errno -13
2024-12-28T11:26:47.755Z [err] npm error Error: EACCES: permission denied, open '/data/package-lock.json'
2024-12-28T11:26:47.755Z [err] npm error     at async open (node:internal/fs/promises:639:25)
2024-12-28T11:26:47.755Z [err] npm error     at async writeFile (node:internal/fs/promises:1212:14)
2024-12-28T11:26:47.755Z [err] npm error     at async Promise.all (index 0)
2024-12-28T11:26:47.755Z [err] npm error     at async [saveIdealTree] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1526:7)
2024-12-28T11:26:47.755Z [err] npm error     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:148:5)
2024-12-28T11:26:47.755Z [err] npm error     at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
2024-12-28T11:26:47.755Z [err] npm error     at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9)
2024-12-28T11:26:47.755Z [err] npm error     at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:74:5) {
2024-12-28T11:26:47.755Z [err] npm error   errno: -13,
2024-12-28T11:26:47.755Z [err] npm error   code: 'EACCES',
2024-12-28T11:26:47.755Z [err] npm error   syscall: 'open',
2024-12-28T11:26:47.755Z [err] npm error   path: '/data/package-lock.json'
2024-12-28T11:26:47.755Z [err] npm error }
2024-12-28T11:26:47.755Z [err] npm error
2024-12-28T11:26:47.755Z [err] npm error The operation was rejected by your operating system.
2024-12-28T11:26:47.755Z [err] npm error It is likely you do not have the permissions to access this file as the current user
2024-12-28T11:26:47.755Z [err] npm error
2024-12-28T11:26:47.755Z [err] npm error If you believe this might be a permissions issue, please double-check the
2024-12-28T11:26:47.755Z [err] npm error permissions of the file and its containing directories, or try running
2024-12-28T11:26:47.755Z [err] npm error the command again as root/Administrator.
2024-12-28T11:26:47.759Z [err] npm error A complete log of this run can be found in: /data/.npm/_logs/2024-12-28T11_26_44_370Z-debug-0.log
2024-12-28T11:26:47.779Z rc=243

Restart your container and try to install node-red-contrib-tasmota from nodered's editor via palette manager.

Use it like this:

services:
   node-red:
    image: nodered/node-red:latest
    restart: unless-stopped
    environment:
      - TZ=Europe/Amsterdam
      - PGID=1000
      - PUID=1000
    ports:
      - "1880:1880"
    networks:
      - node-red-net
    volumes:
      - node-red-data:/data
      #- ./config:/nodered/config
      #- ./data:/nodered/data
      #- ./log:/nodered/log
      #- ./data:/data

volumes:
    node-red-data:

networks:
  node-red-net:

Then again I am not a fan of using volumes like this, I would use a bind mount instead (ie. the parts that are commented out: #- ./data:/data), or better yet, not use docker for node-red.

The problem is, that your container runs with user "node-red" with id "1000:1000" anyway. And as such it cannot access "/data/package-lock.json" because it is owned by root

Stop the container.

Go back to /var/lib/docker/volumes/nodered_node-red-data/_data as root

and chown 1000:1000 package-lock.json

THANKS!!!

Works Love you all..

Nice days and healthy new year

Sow when is set this 2 into my compose file the next time this is going automatic?

I do not think PGID and PUID are needed in this particular case, since standard nodered container are applied with it anyway.

The problems you were facing were that an older instance of nodered, which created persistent data on node-red volume, left files from user root on it. With this neither tasmota nor current nodered could operate anymore. It should be fine now.