Got node red project successfully running in docker. However, can't install new packages from palette because of file permissions.
For example:
-----------------------------------------------------------
2024-09-09T10:31:28.887Z Install : postgrestor 0.0.2
2024-09-09T10:31:28.912Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --omit=dev --engine-strict postgrestor@0.0.2
2024-09-09T10:31:34.092Z [err] npm error code EACCES
2024-09-09T10:31:34.092Z [err] npm error syscall rename
2024-09-09T10:31:34.092Z [err] npm error path /data/node_modules/@openp4nr/modbus-serial
2024-09-09T10:31:34.092Z [err] npm error dest /data/node_modules/@openp4nr/.modbus-serial-S75OrEXy
2024-09-09T10:31:34.093Z [err] npm error errno -13
2024-09-09T10:31:34.093Z [err] npm error Error: EACCES: permission denied, rename '/data/node_modules/@openp4nr/modbus-serial' -> '/data/node_modules/@openp4nr/.modbus-serial-S75OrEXy'
2024-09-09T10:31:34.093Z [err] npm error at async Object.rename (node:internal/fs/promises:782:10)
2024-09-09T10:31:34.093Z [err] npm error at async moveFile (/usr/local/lib/node_modules/npm/node_modules/@npmcli/fs/lib/move-file.js:30:5)
2024-09-09T10:31:34.093Z [err] npm error at async Promise.allSettled (index 16)
2024-09-09T10:31:34.093Z [err] npm error at async [reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
2024-09-09T10:31:34.093Z [err] npm error at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)
2024-09-09T10:31:34.093Z [err] npm error at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
2024-09-09T10:31:34.093Z [err] npm error at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9)
2024-09-09T10:31:34.093Z [err] npm error at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:74:5) {
2024-09-09T10:31:34.093Z [err] npm error errno: -13,
2024-09-09T10:31:34.093Z [err] npm error code: 'EACCES',
2024-09-09T10:31:34.093Z [err] npm error syscall: 'rename',
2024-09-09T10:31:34.093Z [err] npm error path: '/data/node_modules/@openp4nr/modbus-serial',
2024-09-09T10:31:34.093Z [err] npm error dest: '/data/node_modules/@openp4nr/.modbus-serial-S75OrEXy'
2024-09-09T10:31:34.093Z [err] npm error }
2024-09-09T10:31:34.093Z [err] npm error
2024-09-09T10:31:34.093Z [err] npm error The operation was rejected by your operating system.
2024-09-09T10:31:34.093Z [err] npm error It is likely you do not have the permissions to access this file as the current user
2024-09-09T10:31:34.093Z [err] npm error
2024-09-09T10:31:34.093Z [err] npm error If you believe this might be a permissions issue, please double-check the
2024-09-09T10:31:34.093Z [err] npm error permissions of the file and its containing directories, or try running
2024-09-09T10:31:34.093Z [err] npm error the command again as root/Administrator.
2024-09-09T10:31:34.096Z [err] npm error A complete log of this run can be found in: /data/.npm/_logs/2024-09-09T10_31_28_982Z-debug-0.log
2024-09-09T10:31:34.103Z rc=243
Then I tried setting all rights multiple places in Dockerfile. Which seems to have effect on the parent folder.
But taking this specific folder in log file from example, I can't rename it and it contains files with more restrictive permissions.
/data/node_modules/@openp4nr/modbus-serial $ ls -l
total 88
-rw-r--r-- 1 node-red node-red 759 Sep 2 14:26 LICENSE
-rw-r--r-- 1 node-red node-red 6115 Sep 2 14:26 ModbusRTU.d.ts
-rw-r--r-- 1 node-red node-red 9860 Sep 2 14:26 README.md
-rw-r--r-- 1 node-red node-red 2780 Sep 2 14:26 ServerTCP.d.ts
-rw-r--r-- 1 node-red node-red 245 Sep 2 14:26 TestPort.d.ts
drwxrwxrwx 1 root root 512 Sep 3 10:52 apis
drwxrwxrwx 1 root root 512 Sep 3 10:52 examples
-rw-r--r-- 1 node-red node-red 1391 Sep 2 14:26 gulpfile.js
-rw-r--r-- 1 node-red node-red 94 Sep 2 14:26 index.d.ts
-rw-r--r-- 1 node-red node-red 47665 Sep 2 14:26 index.js
drwxrwxrwx 1 root root 512 Sep 3 10:52 node_modules
-rwxr-xr-x 1 node-red node-red 47 Sep 2 14:26 npm-update.sh
-rwxr-xr-x 1 node-red node-red 67 Sep 2 14:26 npm-upgrade.sh
-rw-r--r-- 1 node-red node-red 501 Sep 2 14:26 overwriteRegistryConfigForHotfix.js
-rw-r--r-- 1 node-red node-red 1236 Sep 2 14:26 package.json
drwxrwxrwx 1 root root 512 Sep 3 10:52 ports
drwxrwxrwx 1 root root 512 Sep 3 10:52 servers
drwxrwxrwx 1 root root 512 Sep 3 10:52 test
drwxrwxrwx 1 root root 512 Sep 3 10:52 utils
drwxrwxrwx 1 root root 512 Sep 3 10:52 worker
I wonder if the default Dockerfile sets limited permissions for security reasons? But I'd like to let user add new packages from palette anyway.
Now I could log in as root (exec in docker) and overwrite permissions manually. But prefer to solve this permanently in the Dockerfile.
Suggestions?