How do I properly copy over a flow and a settings.js for Docker deployment of Node Red?
FROM nodered/node-red:latest
# Set working directory
WORKDIR /usr/src/node-red
# Copy package.json and install dependencies (if any)
COPY package.json .
RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production
# Copy your flows.json and settings.js
COPY flows.json /data/flows.json
COPY settings.js /data/settings.js
# Set the user to node-red
USER node-red
# Expose port 1880 for Node-RED
EXPOSE 1880
# Start Node-RED
CMD ["npm", "start", "--", "--userDir", "/data"]
And then I run it with:
docker build -t my-node-red .
docker run -d -p 1880:1880 -v node_red_data:/data --name mynodered my-node-red
Docker builds fine and I can dial into NR but I do not appear to be able see my flow? Any tips greatly appreciated. I am not sure if my settings.js is copying over either...
If I run:
pi@raspberrypi:~/docker_testing $ docker exec -it mynodered ls -l /data
total 44
-rw-r--r-- 1 root root 1373 Feb 15 08:27 flows.json
drwxr-xr-x 3 node-red node-red 4096 Mar 6 16:18 lib
drwxr-xr-x 2 node-red node-red 4096 Mar 6 16:18 node_modules
-rw-r--r-- 1 node-red node-red 120 Mar 6 16:18 package.json
-rw-r--r-- 1 node-red node-red 24649 Mar 6 16:18 settings.js
There does appear to be my flows.json
file but when I dial into NR there is a warning box:
And then someone message within that popup stating I should run the container like:
docker run -it -p 1880:1880 -v /home/user/node_red_data:/data --name mynodered nodered/node-red
But if I run the container with that command:
pi@raspberrypi:~/docker_testing $ docker run -it -p 1880:1880 -v /home/user/node_red_data:/data --name mynodered nodered/node-red
node:fs:3035
binding.copyFile(
^
Error: EACCES: permission denied, copyfile '/usr/src/node-red/node_modules/node-red/settings.js' -> '/data/settings.js'
at Object.copyFileSync (node:fs:3035:11)
at copyFile (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:64:6)
at onFile (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:50:25)
at getStats (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:42:44)
at Object.copySync (/usr/src/node-red/node_modules/fs-extra/lib/copy/copy-sync.js:32:10)
at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:148:20)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12) {
errno: -13,
code: 'EACCES',
syscall: 'copyfile',
path: '/usr/src/node-red/node_modules/node-red/settings.js',
dest: '/data/settings.js'
}
Node.js v20.18.3
Any tips appreciated!!! I want to copy settings.js and flows to a container!!!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744962316a4603463.html
评论列表(0条)