Nodes Credentials not retained after node-red is restarted (docker environment)

Hello,

I've got a little project with node-red running under docker-compose.The node-red setup is installed following the instructions under https://nodered.org/docs/getting-started/docker#docker-stack--docker-compose. I am using a node-red-contrib-mssql-plus node to run some Insert and Select Queries from a MSSQL-Server. Each time i start a new docker-compose build node red loads in my flow which is saved in a flows.json. What it doesn't load is the Login Credentials for the SQL Server. The Username and Password field in the MSSQL-CN configuration node are always empty. Another node that i use, the postgrestor node has the login credentials stored in the flows.json. Is there a way for me to have those credentials automatically loaded ? I can't seem to find a solution in the forum yet.

Thanks in advance.

You wont get help based on that topic. Only people familiar with MSSQL will even look at it (if you're lucky).

I would suggest the issue (as it often seems to be) is docker related (or to be more accurate, your use of docker).

I say that for 2 reasons, 1, docker (if its not absolutely needed) is (IMO) just a massive pain!, 2. this does not happen on normal node-red installations.

My suspicion is the secure credentials are not being persisted (or something else is not being persisted) in the docker env.

Renamed your thread for better chance of a docker expert seeing + helping out (or just dont run in docker!)

Thanks for the quick reply.

I know it's not a pure nodered topic but i thought it would make more sense to post it in the nodered forum than in the docker forums. In my case i think using docker is quite important because i also have a grafana dashboard and a postgres-database running at the same time. Also thank you for renaming the thread!

2 Likes

Are changes to the flow persisted? Have you done anything unusual to specify where the settings or flow file is? If it is not saving the credentials file to a docker volume mapped to the host file system then it will not be persisted.

Hello Colin,
thanks for your answer! I haven't implemented a bind mount yet, but that could be the solution. I am quite new to this topic, so getting ideas from experienced people helps a lot.

At the moment my Dockerfile looks like this:

FROM nodered/node-red:1.0.4

COPY node-red/flows.json /data/flows.json
COPY node-red/settings.js /data/settings.js

RUN npm install node-red-contrib-mssql-plus
RUN npm install node-red-contrib-postgrestor-next
RUN npm install node-red-contrib-watchdirectory

CMD ["npm", "start"]

You don't appear to have answered that. If you make changes to the flow in node-red and then restart the container do the changes stick?

I was trying to answer that with the dockerfile. When i want to restart the container i have to manually export the flows and then save them into the flows.json file which is then imported via the dockerfile.

Implementing a bind-mount and importing it via the dockerfile works for me! Thanks for the help :slightly_smiling_face:

For reference, credentials are stored in xxxxx_cred.json and your docker image didnt contain a COPY line for a cred json file.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.