Please help me "moving" Node-Red docker to docker compose. (retaining data)

My nodered is currently based on
docker run -it -p 1880:1880 -p 161:161/udp -p 162:162/udp --name noderednew nodered/node-red
docker start noderednew

yes, I am aware of Running under Docker : Node-RED

if I added this section to my docker-compose.yml ...

services:
  node-red:
    image: nodered/node-red:latest
    environment:
      - TZ=Europe/Amsterdam
    ports:
      - "1880:1880"
      - "161:161"
      - "162:162"
    volumes:
      - node-red-data:/data

..then I would not expect it to work, I mean ... something should be renamed to "noderednew" (as the current name is that.)

I would really like to change the service name from "noderednew" to "nodered - and just lest docker compose run it, with all the current data.
How should I proceed?

D-C is really just a management wrapper around the docker runtime to allow you to create, maintain, stop/start projects containing one or more docker images, with a declarative YAML interface. The D-C project will use the same nodered image and so long as you map the same named volume to this, then the new project container will inherit the same runtime environment. I assume that you have read and are familiar with the Running under Docker tutorial.

It is always wise to create a regular backup of your project especially before doing this sort of experiment; you can use the docker cp technique discussed in the tutorial. Alternatively you can do an exec /usr/bin/tar ... to stdout pipe this to a host file. Be aware that the container uses Alpine as its Linux OS, so tar is the simpler busybox version. Again, the tutorial explains how to log into a bash shell in the container. You use this to debug your tar command. You might also want to bracket the tar command with a service nodered stop and start.

BTW, (i) why are you exposing SNMP to the host ports? I am not sure why you'd do this. (ii) why use the "Europe/Amsterdam" TZ (other than this is the one referenced in the tutorial)?

So, you are saying that with a proper docker-compose.yml , I can just make it use/run the current installation/data.
i : I am using SNMP for UPS monitoring. (node-red-snmp-trap-listener)
ii : I just kept "Europe/Amsterdam" because it works fine for me (being in UTC+1) - I guess you are implying I should just remove it? (use system setting?)

Thank you.

i. yes but D-C has a naming convention that prefixes the reference volume name with the project, so a docker volume ls will list myproject_node-red-data as well as node-red-data and so won't pick up the same volume by default. There are standard tricks for doing this move but these hints can be found on StackOverflow, not here. Or you could just do a backup and restore to move the content as discussed above. Also note the usual issue about nodered embedding the hostname in the flow filename by default.

ii. I hate using any timezone other than UTC for process control because of when daylight savings applies and when it doesn't. Working in UTC avoids all this, but if your project uses a Central Europe TZ and works fine then don't change.

1 Like

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