Deployed flow in Azure Container Instances disappears

I have used Azure Container Instances to stand-up different Node-Red containers multiple times.
It is quickly done and everything seem to go as intended.

I can access and deploy Node-Red flows without any problems, set up HTTP In nodes that are
publicly available and save some Flow Variables to keep state (used for required user settings).

Without warning though, at some time, the deployed flows are all deleted, likely because the container restarted and pulled the Node-Red image automatically again.

Why does it do that? How can I keep my flows intact? Do I have to create Container Groups in order to make this more stable?

Hello @tobiaspe
I have noticed similar problems when running node-red in Kubernetes. For me, the problem was that the flow files are postfixed with the hostname, and every time a new container was created the hostname changed. Try setting the flow file to a fixed name in the settings.js and see if that helps.

You will also need to define a static volume that you mount the user-data folder in so that those files are kept during recreation.

Let me know if you need any more input.

Regards
Bernt-Johan

For more info see - https://github.com/node-red/node-red-docker/blob/master/volumechanges.md

1 Like

The two things that you need to do are documented in here already but to emphasise:

  • You should configure a fixed name for the settings.js file (which is the default I think in the docker image)
  • You must configure a persistent storage volume to be mounted on /data otherwise you will indeed lose your flows every time you redeploy.
1 Like

Hi @tobiaspe,

The flows you create/edit are stored under the /data folder.
It is important that the /data folder is mounted to a docker volume in order to assure that you don't loose the flows you have edited/created when replacing the docker image with a new docker image version.

See also following node-red documentation:

Does this help ?

jan

I did some further digging in the azure documentation:

So when you stop your container group it recycles everything - so the container state is not preserved.
So if flows are stored in the writable container layer they are all lost.

When restarting a container it will pull a new image if the container image is updated which most likely is the case as recently a new node-red image version is available on docker hub.
So this new image, will complete replace the old image including the writable container layer containing the flows you have stored there.

To overcome this you must assure that the flows are not stored in the writable container layer but outside the container in a volume.

So for this you need to

  1. create an Azure file share:
    Mount Azure Files volume to container group - Azure Container Instances | Microsoft Learn
  2. mount the Azure file share as a volume in the container with mount path /data
2 Likes

Thanks a million for all your replies, they were all very very valuable and I now understand much more on what I need to setup to make my flow persist over a container restart/repull.

But a really stupid question. am I to run the CLI and command within the "Connect To" using Bash in my actual Container Instance? Or do I somehow access the Container Instance container from Docker? How do I run the examples on how to set this up through/to my deployed Node-Red container?

I have deployed through the Azure Portal as described in https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quickstart-portal and used the latest Node-Red image from Docker Hub.

It is not fully clear what you want to do ? Which examples do you want to run ?
Using node-red editor you can easily import flows that you have copied to the clipboard.

Well, I would like to interact with the ACI Container, or rather the underlying Settings file. How do I connect to the underlying files of the Node-Red container. From the Azure Portal I can use Connect and then run bash commands (see screen dump).

Is there another way of interacting with underlying Node-Red container and its files?

Do you want to change the node-red settings file ?
I think you can find it at location /data/settings.js
If it is it not there then try creating a setting.js in that location.
Take care that you need to stop and start node-red container in order to assure it will take your file changes into account.

Yes, but where do I do that?

Do I access the container from inside the Azure Portal?

Using Connect directly under the Azure Container Instance using Bash commands?

Where do I run any similar commands and access the Node-Red files?

Yes, that is a way you can do it. I guess you can use nano, vi or vim as editor for editing the settings file.

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