NodeRED Docker image with TimeZone options

Hi, I have looked a lot and I have found many "How to" with no success. Small things like when you type in the line, the command is unknown in the Docker image I have.

So, I used IOTStack as well as the official! Docker image and I failed in what I need to do.

My problem:
I have several flows that use an Inject Node, these all seem to take the time que from the Docker Container which is stubbornly UTC.
On the base system the time zone is Europe/Madrid and the Inject node takes this as its que to trigger.
I have terminal'ed into the container and followed lots of example all to no avail.
Currently if I want to trigger at 18:00 I now have to set the Inject Node to trigger at 16:00 which is great and it works but is just wrong. (I will mess this up).

I have also installed the Docker image for Home Assistant, this knows the correct time and thinks it lives in Spain, it does.

So, is there a Nodred Docker image that has this "TZ", "TimeZone" facility or can I add it?

I am using the IOPStack "IOTstack" to start with.
I have tried the Docker "most recently updated and 10m+ download" images.
Neither seemed to work.

I am using a Raspberry Pi4 with the latest Raspbrian!

Any other info I can provide, I have looked but if you know where I can go to find this out, please let me know, if you know the answer, brilliant.

My standalone Nod-red works perfectly now, it's is just the move to Docker that has me beat.

I think you just need to set the environment variable TZ when running/starting your container.

E.g. I have set it to TZ=Europe/Brussels and this is working for me.

Here below a log when attaching a shell to my node-red container.

bash-5.0$ date
Thu Apr 29 13:33:42 CEST 2021
bash-5.0$ echo $TZ
Europe/Brussels
bash-5.0$ 

I am setting this environment variable in my docker-compose file (see below) as I am using docker-compose files to specify my containers but I guess you can also specify it somewhere when using IOTstack.

Here below an extract from my docker-compose file where I have set that env variable.

version: "3.7"
volumes:
  share:
  nr-mydrive-ctrl-data:
  inotify-data:
services:
 ...
 nr-mydrive-ctrl:
    build: nr-mydrive-ctrl
    volumes:
      - share:/share
      - inotify-data:/var/inotify
      - nr-mydrive-ctrl-data:/data
    ports:
      - "5880:1880"
    cap_add:
      - SYS_ADMIN  # is needed for mounting a samba share in container
    restart: always
    env_file:
      - .env.node-red
    environment:
      - TZ=Europe/Brussels
      - NODE_RED_ENABLE_PROJECTS=true 
...
1 Like

I am sorry I have not replied to this quicker but I have been distracted.
I have tried to do this, or something like this to no effect but I will be having another look with your help, thanks.
It is always possible I missed something and here is the answer, I will try and get back to say yes, or no. Thansk again.

If you do not have the Compose files (i.e. you have taken prebuilt Images) you can instead run Portainer after the image is running and use it to create a new image with the nevessary envirionment variables for timezone set correctly

Craig

2 Likes

Thanks, as above, distracted from this for a few days but need to fix it as the way ahead, I want! needs me to fix this. It seems that is lack of experience on my part so far. Soon to be fixed, thanks.

First, I have solved it now. I was nearly there but, as implied, not really got a clue as I am new to this Docker thing.
So what helped?
First off, knowing that I have the right idea about the time zone environment variable,
Janvda's, extract of the, compose file was a great help, I had gone round in circles and had made a wrong choice and I ended up putting in invalid data! So a good start.
When trying to follow craigurtin´s advice, new to Portainer as well, and create a new container with the desired options, which I was struggling with, I suddenly discovered that I could modify an existing container which threw up my incorrect TZ variable.
I corrected this and boom, job done.
So, now Node Red does events at my local time and I can mode my flows to the new machine.
Thanks, learnt a lot.

2 Likes