Reputation: 31
I tried for so many hours now and tried so many things that I have to ask now. On my docker I can't get nodered to run on it. I get permissions error for the shared volume all the time. My other container for "fhem" does run with the same folder permissions. So i don't get why its a problem for nodered.
Currently I'm using ubuntu on the latest version.
I want to store the /data folder from the nodered instance in /opt/docker-nodered but this doesn't work.
I tried to install it with the following command:
docker run -it -p 1880:1880 -v /opt/docker-nodered/:/data --name nodered nodered/node-red-docker
The permissions here are the following:
stefmde@homeautomation:/opt$ ll
total 16
drwxr-xr-x 4 stefmde stefmde 4096 Sep 24 09:52 ./
drwxr-xr-x 23 root root 4096 Sep 21 18:56 ../
drwxr-xr-x 10 stefmde stefmde 4096 Sep 22 12:48 docker-fhem/
drwxr-xr-x 2 stefmde stefmde 4096 Sep 24 14:01 docker-nodered/
I changed them with the following to try to get it running:
chown -R stefmde:stefmde /opt/docker-nored
But no mather what I try, I always get the same error:
stefmde@homeautomation:/opt/docker-nodered$ sudo docker run -it -p 1880:1880 -v /opt/docker-nodered/:/data --name nod ered nodered/node-red-docker
> [email protected] start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
fs.js:642
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open '/data/settings.js'
at Error (native)
at Object.fs.openSync (fs.js:642:18)
at copyFileFallback (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:93:18)
at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:85:10)
at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:58:12)
at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:51:39)
at startCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:41:10)
at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:36:10)
at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:104:20)
at Module._compile (module.js:577:32)
npm ERR! Linux 4.15.0-34-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--" "--userDir" "/data"
npm ERR! node v6.14.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-red-docker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-red-docker
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-red-docker
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/src/node-red/npm-debug.log
The npm.debug.log-file doesn't exist
I tried different permission sets, I checked the UUID which is 1000 of my user, I tried to run "npm install" manually, checked different bug tickets on github, tried the "--User"-Flag which isn't working, running the docker command with and without "sudo" and so on.
Please can someone try to help me or tell me what i did wrong? I hope you could :)
Upvotes: 2
Views: 6822
Reputation: 73984
I was able to fix this by just creating the local folders BEFORE starting docker/compose, so it does not create them as root user.
Upvotes: 0
Reputation: 59638
The node-red docker container runs as the user node-red
, a lot of other docker containers run the application as the default user, which happens to be root.
At the moment your docker-nodered
directory is only writable by the user stefmde
and root
(because root can write to anywhere)
The quick solution is to make the docker-nodered
writable by anybody (chmod o+w docker-nodered
) this should work.
The longer solution will be to work out what the UID of the node-red
user is, add a group to the host OS that has a member with the same UID as node-red
and make the directory owned by that group and then make it group writable (chmod g+w docker-nodered
)
EDIT: The default uid:gid for the node-red user is 1000:1000
Upvotes: 5
Reputation: 1117
By far, the easiest method is to change ownership of the Node-RED data folder to user 1000 and group 1000, as this is hard-coded in the Node-RED docker container:
sudo chown 1000:1000 name-of-node-red-data-folder
Upvotes: 2
Reputation: 1442
I've workaround that worked for me using docker-compose. I've created the file docker-compose-node-red.yml
with the following content:
version: "3.7"
services:
node-red:
image: nodered/node-red:latest
ports:
- "1880:1880"
volumes:
- "/path/to/a-nodered-project:/data"
Then, I run
$ docker-compose -f docker-compose-node-red.yml up
In the folder /path/to/a-nodered-project
I have a flows.json file and others. Everything is accessible from the node-red container perspective.
Upvotes: 0