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

**URL:** https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364
**Category:** General
**Created:** [27 May 2020 09:03 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364 "2020-05-27T09:03:15Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![schmidki](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@schmidki](https://discourse.nodered.org/u/schmidki)
#### Post date: [27 May 2020 09:03 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/1 "2020-05-27T09:03:15Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 May 2020 09:57 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/2 "2020-05-27T09:57:25Z")

</div>

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!)

---

<div class="post-metadata">

### Author: ![schmidki](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@schmidki](https://discourse.nodered.org/u/schmidki)
#### Post date: [28 May 2020 09:04 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/3 "2020-05-28T09:04:15Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [28 May 2020 09:44 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/4 "2020-05-28T09:44:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![schmidki](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@schmidki](https://discourse.nodered.org/u/schmidki)
#### Post date: [2 June 2020 07:50 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/5 "2020-06-02T07:50:06Z")

</div>

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:

```auto
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"]

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 June 2020 08:12 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/6 "2020-06-02T08:12:40Z")

</div>

> [@Colin](#):
>
> Are changes to the flow persisted?

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?

---

<div class="post-metadata">

### Author: ![schmidki](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@schmidki](https://discourse.nodered.org/u/schmidki)
#### Post date: [2 June 2020 08:19 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/7 "2020-06-02T08:19:38Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [2 June 2020 10:41 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/8 "2020-06-02T10:41:00Z")

</div>

> [@Steve-Mcl](#):
>
> My suspicion is the secure credentials are not being persisted (or something else is not being persisted) in the docker env

> [@schmidki](#):
>
> ```auto
> 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"]
> 
> ```

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [16 June 2020 10:41 UTC](https://discourse.nodered.org/t/nodes-credentials-not-retained-after-node-red-is-restarted-docker-environment/27364/9 "2020-06-16T10:41:08Z")

</div>

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