(solved) Node-Red docker using another uid: error on adding packages


Hi, fired up a rpi, added docker. I deleted "pi" uid (sec reasons), added user "node-red" (uid = 1001), and group "node-red" (uid = 10050). The official node-red docker instructions warns when you delete use 1000, that you should start node-red with the --user command, and yes - I experienced this. So, the command that get docker node-red started properly looks like this:

docker run -it -p 1880:1880 --user=node-red:node-red -v /home/node-red/iotplay/rhm_dig2/data:/data  --name testdock nodered/node-red-docker:rpi-v8

... of which the folder /home/node-red/iotplay/rhm_dig2/data have been created by user & group node-red ...

All good..... so far. But, when I try to add a package (like node-red-dashboard), I get the following error, inside the docker logs of node-red:

│           npm update check failed            │
│     Try running with sudo or get access      │
│     to the local update config store via     │
│ sudo chown -R $USER:$(id -gn $USER) /.config │

Further errors in the npm-debug.log file, shows the following errors, obviously a rights & access issue:

80 error Linux 4.14.79-v7+
81 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "--save-prefix=~" "--production" "node-red-dashboard@2.13.0"
82 error node v6.11.0
83 error npm  v3.10.10
84 error path /.npm
85 error code EACCES
86 error errno -13
87 error syscall mkdir
88 error Error: EACCES: permission denied, mkdir '/.npm'
88 error     at Error (native)
88 error  { Error: EACCES: permission denied, mkdir '/.npm'
88 error     at Error (native)
88 error   errno: -13,
88 error   code: 'EACCES',
88 error   syscall: 'mkdir',
88 error   path: '/.npm',
88 error   parent: 'node-red-project' }
89 error Please try running this command again as root/Administrator.

The error occurs with both node versions v8 and v6 on RPi.

I previously ran this type of config successfully.



An update, running as root allows installation, thus I now need to go find what about the user is causing this...

The following works:

docker run -it -p 1880:1880 --user=root:root  -v /home/node-red/iotplay/rhm_dig2/data:/data/  --name testdock nodered/node-red-docker:rpi-v6


Okay, this command chmod -R a+rw \data solves the problem. Got it here