Search code examples
dockernode-redazure-iot-edge

How to provide write permissions to the data directory when deploying Node-red on Azure IoT edge device?


Raspberry Pi 3 Model B Plus Rev 1.3 Debian GNU/Linux ARM32v7

Dear community members,

I am trying to install Node-Red module on Azure IoT Edge device as it described in https://github.com/iotblackbelt/noderededgemodule. However, I am facing the following problem: there is no permission for the node-red container. I tried to start docker image of node-red, though it didn't work. As I understood I need to give permission to the docker container. How to do it?

I receive the following logs:

> [email protected] start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"

internal/fs/utils.js:269
    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:1882:3)
    at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:68:8)
    at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:53:25)
    at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:48:44)
    at startCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    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:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) {
  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! [email protected] 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 [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Solution

  • The important bit that should have been in the question appears to be

        "Binds": [
            "/node-red:/data"
        ],
    

    This implies that the directory /node-red is mounted in /data

    You need to ensure that uid 1000 can write to this. The quickest way is probably to run:

    sudo chown 1000:1000 /node-red