Docker/Portainer gives Error: EACCES: permission denied, copyfile -> '/data/settings.js'

I am trying to install Node-RED using Docker/Portainer on my Pi4 running Raspbian but I'm getting permission errors when the container starts up. From the error message, this is a permission problem. I have tried creating/assigning a non-admin account to the container but it does not fix the problem. Any suggestions on how to fix this using Portainer?

In Portainer, I have setup:

Name: Node-RED
Image: nodered/node-red:latest
Ports: `host`: 1880 => `container`: 1880
Volumes: /home/user/HAStack/node-red:/data (bind)
Network: Host

When I deploy the container, the log shows the following errors:

> node-red-docker@2.0.6 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"

internal/fs/utils.js:314
    throw err;
    ^

Error: EACCES: permission denied, copyfile '/usr/src/node-red/node_modules/node-red/settings.js' -> '/data/settings.js'
    at Object.copyFileSync (fs.js:2059:3)
    at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:70:6)
    at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:56:25)
    at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:48:44)
    at handleFilterAndCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
    at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
    at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:125:20)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32) {
  errno: -13,
  syscall: 'copyfile',
  code: 'EACCES',
  path: '/usr/src/node-red/node_modules/node-red/settings.js',
  dest: '/data/settings.js'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@2.0.6 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-red-docker@2.0.6 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

See the permissions notes in the documentation under "Managing User Data"

1 Like

Ok, so, using my Portainer volume bindings above, I needed to either create the folder /home/user/HAStack/node-red ahead of time using the pi account, or chown pi:pi /home/user/HAStack/node-red.

Now it's working fine.

So simple, yet I spent the afternoon searching for this answer. THANKS @bakman2 !