Import flow via CLI on Node-RED under Docker

#1

I have a Node-RED server that i need to be under docker following this docs:https://nodered.org/docs/platforms/docker#customising

But after running:

docker run -it -p 1880:1880 --name mynodered nodered/node-red-docker

I need to import a flow from "flow.json" local file into it.

How to do that?

When i run: docker run -it -p 1880:1880 -v ~/node-red-data:/data --name mynodered nodered/node-red-docker

I get:

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

fs.js:1918
  binding.copyFile(src, dest, flags);
          ^

Error: EACCES: permission denied, copyfile '/usr/src/node-red/node_modules/node-red/settings.js' -> '/data/settings.js'
    at Object.fs.copyFileSync (fs.js:1918:11)
    at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:66:8)
    at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:51:37)
    at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:46:44)
    at startCopy (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:36:10)
    at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:31:10)
    at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:108:20)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@1.0.0 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 node-red-docker@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/src/node-red/.npm/_logs/2019-03-22T17_24_10_761Z-debug.log`

Thank you all! <3

0 Likes

#2

check the permissions on the directory and its files.

1 Like

#3

Thanks mate, it helped but how i set

docker run -it -p 1880:1880 -v ~/node-red-data:/data --name mynodered nodered/node-red-docker

On actual folder like:

docker run -it -p 1880:1880 -v ./node-red-data:/data --name mynodered nodered/node-red-docker

TY!

0 Likes

#4

Solved with:

docker run -it -p 1880:1880 --user=root:root -v $(pwd)/node-red-data:/data --name mynodered nodered/node-red-docker

:)) Thanks bro

0 Likes