I was playing with the inject node to send at a specific time and long story short found out that my ubuntu server time was not correct and same with my node-red docker container. I was able to update ubuntu to the correct time zone, but not sure how to do this in docker. I have a ubuntu server running docker, but I am just starting out so still learning.
I have had this in my bookmarks for two years specifically because of Docker. LOL
Yes you obviously set up Ubuntu Server with UTC in the first place. Rather than reproduce what it says here just follow this link https://bobcares.com/blog/change-time-in-docker-container/
GMTA
LOL… I did find this article last night, but I couldn’t get past this part trying option 2.
Also there was some posts I found about attaching to the container, but when I do it’s just a blinking cursor
When you use docker attach
you are attaching to whatever the container was setup to run. You should use docker exec
with bash
to connect as in your first code snippet. Alternatively, install Portainer as it gives you a browser-based console.
sudo docker exec -it addon_a0d7b954_nodered /bin/bash
However, any changes you make inside the container are unlikely to outlive a reboot.
The docker container for Node Red sets up the TZ environment variable. I’m assuming this comes from /etc/timezone
. The first thing to do would be to check the contents of that file on Ubuntu. If it’s wrong, Google how to change the timezone on Ubuntu (the file is a symbolic link, so you can’t just edit it). Then restart HA and see if it picks up the correct timezone. You can check the TZ environment variable in Portainer, or using
sudo docker exec -it addon_a0d7b954_nodered env
If they don’t match, it perhaps suggests the NR add-on only reads it during installation. In this case you might have to uninstall and re-install the addon (backup your flows first).
Thank you for the explanation! I ended up creating my first docker compose file and time is correct even on reboots of the container!