gpt4 book ai didi

docker - 使用resin.io部署时如何更新node-red/node-red-docker镜像中的settings.js?

转载 作者:行者123 更新时间:2023-12-02 18:14:42 30 4
gpt4 key购买 nike

我正在使用具有以下内容的 Dockerfile,我在树莓派上使用 resin.io 进行部署。

FROM nodered/node-red-docker:rpi-v8
USER root
RUN sudo setcap 'cap_net_bind_service=+ep' $(eval readlink -f `which node`)
USER node-red

我还想更新 Node-RED 使用的 settings.js,但我不知道该怎么做。

我创建了一个文件 settings.js 并将以下行添加到我的 Dockerfile 中,就在 RUN 命令之后......它确实构建并由 resin.io 部署,没有任何错误。
COPY settings.js /data/

...但是在检查 /data/ 文件夹时,我发现 settings.js 没有更新。我仍然可以看到由先前部署和容器启动自动创建的旧 settings.js

仅供引用我的容器的 /data 文件夹的内容:
node-red@997563c:~$ ls -l /data
total 24
-rw-r--r-- 1 node-red node-red 283 Oct 28 08:57 flows.json
drwxr-xr-x 3 node-red node-red 4096 Oct 27 10:44 lib
drwxr-xr-x 3 root root 4096 Oct 26 22:27 node-red
-rw-r--r-- 1 node-red node-red 120 Oct 27 16:44 package.json
-rw-r--r-- 1 node-red node-red 8091 Oct 27 10:44 settings.js
node-red@997563c:~$

仅供引用,在包含 Node-RED 应用程序启动的容器日志文件下方:
28.10.18 11:18:03 (+0100) Starting service 'main sha256:472f9797c9288bc3d5a9147597fd33fb982ab34f4eb0e467f70842f05a421f3b'
28.10.18 11:18:04 (+0100) main mount: only root can use "--types" option
28.10.18 11:18:04 (+0100) main mount: only root can use "--move" option
28.10.18 11:18:04 (+0100) main mount: only root can use "--move" option
28.10.18 11:18:04 (+0100) main mount: only root can use "--move" option
28.10.18 11:18:04 (+0100) main mount: only root can use "--move" option
28.10.18 11:18:04 (+0100) main umount: /dev: umount failed: Operation not permitted
28.10.18 11:18:04 (+0100) main mount: only root can use "--move" option
28.10.18 11:18:04 (+0100) main ln: cannot remove ‘/dev/ptmx’: Permission denied
28.10.18 11:18:04 (+0100) main mount: only root can use "--types" option
28.10.18 11:18:04 (+0100) main /sbin/udevd
28.10.18 11:18:04 (+0100) Started service 'main sha256:472f9797c9288bc3d5a9147597fd33fb982ab34f4eb0e467f70842f05a421f3b'
28.10.18 11:18:05 (+0100) main npm info it worked if it ends with ok
28.10.18 11:18:05 (+0100) main npm info using npm@5.0.3
28.10.18 11:18:05 (+0100) main npm info using node@v8.1.3
npm info lifecycle node-red-docker@1.0.0~prestart: node-red-docker@1.0.0
npm info lifecycle node-red-docker@1.0.0~start: node-red-docker@1.0.0
28.10.18 11:18:05 (+0100) main
28.10.18 11:18:05 (+0100) main > node-red-docker@1.0.0 start /usr/src/node-red
28.10.18 11:18:05 (+0100) main > node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
28.10.18 11:18:05 (+0100) main
28.10.18 11:18:08 (+0100) main 28 Oct 10:18:08 - [info]
28.10.18 11:18:08 (+0100) main
28.10.18 11:18:08 (+0100) main Welcome to Node-RED
28.10.18 11:18:08 (+0100) main ===================
28.10.18 11:18:08 (+0100) main
28.10.18 11:18:08 (+0100) main 28 Oct 10:18:08 - [info] Node-RED version: v0.19.4
28.10.18 11:18:08 (+0100) main 28 Oct 10:18:08 - [info] Node.js version: v8.1.3
28.10.18 11:18:08 (+0100) main 28 Oct 10:18:08 - [info] Linux 4.14.39 arm LE
28.10.18 11:18:09 (+0100) main 28 Oct 10:18:09 - [info] Loading palette nodes
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] Settings file : /data/settings.js
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] Context store : 'default' [module=memory]
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] User directory : /data
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [warn] Projects disabled : editorTheme.projects.enabled=false
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] Flows file : /data/flows.json
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] Server now running at http://127.0.0.1:80/
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [warn]
28.10.18 11:18:12 (+0100) main
28.10.18 11:18:12 (+0100) main ---------------------------------------------------------------------
28.10.18 11:18:12 (+0100) main Your flow credentials file is encrypted using a system-generated key.
28.10.18 11:18:12 (+0100) main
28.10.18 11:18:12 (+0100) main If the system-generated key is lost for any reason, your credentials
28.10.18 11:18:12 (+0100) main file will not be recoverable, you will have to delete it and re-enter
28.10.18 11:18:12 (+0100) main your credentials.
28.10.18 11:18:12 (+0100) main
28.10.18 11:18:12 (+0100) main You should set your own key using the 'credentialSecret' option in
28.10.18 11:18:12 (+0100) main your settings file. Node-RED will then re-encrypt your credentials
28.10.18 11:18:12 (+0100) main file using your chosen key the next time you deploy a change.
28.10.18 11:18:12 (+0100) main ---------------------------------------------------------------------
28.10.18 11:18:12 (+0100) main
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] Starting flows
28.10.18 11:18:12 (+0100) main 28 Oct 10:18:12 - [info] Started flows

仅供引用我的 docker 容器的 df 输出:
node-red@997563c:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
none 6794760 748316 5677608 12% /
tmpfs 65536 0 65536 0% /dev
/dev/mmcblk0p6 6794760 748316 5677608 12% /data
none 306201 245637 40494 86% /lib/modules
tmpfs 499556 0 499556 0% /tmp/resin
shm 65536 0 65536 0% /dev/shm
tmpfs 499556 10024 489532 3% /host/run/dbus
node-red@997563c:~$

第一次更新(2018-10-28):

以下 2 个链接描述了如何将 settings.js 作为 node-RED 的 Docker 构建脚本的一部分提供。所以这在技术上是可行的,但目前我不知道如何使用官方 nodered/node-red-docker 存储库来做到这一点
  • https://github.com/resin-io-projects/balena-node-red
  • https://medium.com/@knolleary/deploying-node-red-applications-to-devices-using-resin-io-58d2042cdb0c
  • 最佳答案

    好的,所以问题将是 `/data' 被安装在 docker 镜像中的任何内容之上。
    /data的内容将由您推送到resin.io 设备的先前版本的docker 镜像设置。

    我可以看到 2 个选项:

  • 删除整个图像并重新开始。这只有效,因为你在“玩”。这在生产环境中是不可能的。
  • 登录容器并编辑/替换settings.js并重启
  • 关于docker - 使用resin.io部署时如何更新node-red/node-red-docker镜像中的settings.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53030286/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com