在Docker中更改Node_RED设定setting.js过程

本文档详细介绍了在Docker环境下配置Node-RED的settings.js文件的过程。由于默认情况下settings.js文件不可编辑,作者通过研究发现应将其挂载到userDir目录。在尝试修改容器内的settings.js时遇到了找不到文件的问题,最终在GitHub上找到Node-RED的目录结构,并通过SSH进入Docker容器,定位到正确的settings.js文件位置。在修改adminAuth部分并启用权限管理后,成功实现了Node-RED的登录功能。
部署运行你感兴趣的模型镜像

在Docker中部署了Node-RED,但是没有登录界面,经查询发现是https://nodered.org/docs/configuration所列出问题

但是,在DOcker安装的WEbui,portainer console中没有setting.js,所以网上搜索了一下,找到一下答案

You should not change the copy of settings.js in /usr/src/node-red this is the default and should be left alone. Also editing this file after starting the container will not work as it is copied to the userDir the first time Node-RED is started.

If you want to include your own version you should mount it into the /data directory as this is the userDir for the system when running.

You can use the docker -v option to mount a local copy of the file into the container.

docker -v /path/to/settings.js:/data/settings.js ...

shareimprove this answer

edited Feb 5 at 11:40

answered Feb 4 at 18:54

hardillb

26.2k73564

  • Ok, I will try to mount it on userDir. "You should not change the copy of settings.js in /usr/src/node-red this is the default and should be left alone. Also editing this file after starting the container will not work as it is copied to the userDir the first time Node-RED is started." For this, there is no default copy of setting.js file, this file don't exist inside the continer – Martina Pesca Bellio Feb 5 at 11:40 

  • It doesn't matter where the default is in the container (it will probably actually be under /usr/local/lib/node_modules/node-red), you should not be modifying it anyway. just mount your own version into /data which is the userDir (equivalent to ~/.node-red normally) – hardillb Feb 5 at 11:47

#但是实际上 这个setting.js文件在哪里呢?

开始我真的信了网上的内容,但是我进入node-red官方github后,发现了他的目录结构

node-red/packages/node_modules/node-red/

重新返回docker的webui,portainer里,打开console,root身份进入(请注意灰色的root只是提示还是要输入root),然后找到了setting.js文件目录:

root@4fg4a35bz918:/usr/src/node-red/node_modules/node-red#

然后开始安装编辑器,是的,得自己拉下来,小白白最爱nano

执行之后告诉我E: Unable to locate package nano

好的,apt-get update,然后就好了

终于进去了,可以修改参数了

gavin

## 我主要修改的就是用户登录

但是我发现这种方式刷新还是太慢了,字都重叠了。直接ssh然后

sudo docker exec -it {container——name} bash

用伪终端进入docker进行编辑settings.js,进入后发现

adminAuth全部被注释,所以没有权限界面显示。

gavin

将“//” 删除,就可以启用Node-RED权限分级功能。密码是MD5的password,就是这几个字符就是登录密码。

然后,没有任何变化。小白毕竟是小白,注意,我的工作目录是/usr/src/node-red/,我想当然的就去找settings.js。

其实分析一下逻辑关系就知道,我工作在Docker环境下,也就是虚拟机下,那么我进入的虚拟环境里面只能有Node-RED全部内容,所以我应该退到最后根目录,然后我看到了

gavin

这才是Node-RED的工作目录全貌,进入data目录,后看到了真正需要修改的settings.js然后一切就正常了

gavin

 计算新的密码,需要以下命令

node -e "console.log(require('bcryptjs').hashSync(process.argv[1], 8));" your-password-here

计算出的字符串 替换

您可能感兴趣的与本文相关的镜像

voxCPM-1.5-WEBUI

voxCPM-1.5-WEBUI

PyTorch
语音合成
音乐合成

文本转语音大模型,网页推理。

评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值