Comments (27)
Sometimes the host distro has a /etc/timezone while others have /etc/TZ.
One of these should work:
docker run -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro
docker run -v /etc/localtime:/etc/localtime:ro -v /etc/TZ:/etc/timezone:ro
(synology nas)
Hope this helps!
from node-red-docker.
Would it be possible to add TZ as an environment variable? I'd estimate about 90% of my current containers take it, so it took a minute to figure out why my time-based flows weren't working correctly. It would be a nice quality of life improvement if nothing else. Thanks!
from node-red-docker.
Using the nodeRed v8 docker and TZ does not work (at least not in Synology GUI Docker). It just defaults to UTC even with the variable set.
I also tried doing the symlinks above and that didn't fix the time. I'm assuming clearing the container should be sufficient (we don't need to fully delete it do we?). I made symlinks for both TZ and localtime then pointed TZ to /etc/timezone and localtime to /etc/localtime in the container but the time never adjusted. "cat /etc/timzene" and "cat /etc/localtime" in the container did show the correct information, however. But the time on any triggers, nodes, etc was still wrong and defaulting to UTC.
from node-red-docker.
I am running with -e TZ="America/New_York" and still my inject nodes seem to only fire on GMT / UTC time.
Edit: For anyone else that finds themselves here, @mabunixda's suggestion seemed to be the only thing that worked for me, although I found recommendations to also map "/etc/timezone" through to the docker instance. I am unsure if that is strictly necessary, but found multiple recommendations to do so. My run command now looks more like this:
docker run -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -e TZ=America/New_York ...
from node-red-docker.
Update incase anyone else is having trouble with the above also: I finally got it to work by stopping the Node-Red docker in GUI, going in to SSH for DSM, then running:
docker run -it -p 1880:1880 -v /volume1/docker/Node-Red:/data -v /etc/localtime:/etc/localtime:ro -v /etc/TZ:/etc/timezone:ro -e TZ=America/New_York --name nodered8 nodered/node-red-docker:v8
I then deleted the old docker.
After that it seems you don't need to use SSH anymore, it will appear in your Synology Docker GUI and can be stopped/started, etc from there. Not sure why the symlink and other solutions didn't work with the existing docker.
from node-red-docker.
After wasting some time on this issue:
In dockerized node-red you have 3 timestamps:
- docker host time
- docker container time
- node red front-end time
Each can have its own different time zone setting, time update/synch status and current time.
unless your docker host is synched and have correct time zone and ntp synched, the docker compose time zone environemnt variable (TZ), will not produce the correct time for the docker container and timestamp inject node will not produce the correct time (regardles of the time related volumes mappings mensioned in previous proposed solutions).
So first verify your host has the correct time (by issueing a $date command in the host machine environment)
then issue a $date ecommand inside the container bash environment to make sure the time stamps are identical.
then on node red canvas create a timestamp inject node connected to the following function node:
var date = new Date();
// Hours part from the timestamp
var hours = date.getHours();
// Minutes part from the timestamp
var minutes = "0" + date.getMinutes();
// Seconds part from the timestamp
var seconds = "0" + date.getSeconds();
// Will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
//console.log(formattedTime);
msg.payload = formattedTime;
return msg;
connect debug node and check the time message on the debug console, verify its identical to the container and host time stamps.
from node-red-docker.
@icanic just map /etc/localtime into the container
docker run -v /etc/localtime:/etc/localtime
from node-red-docker.
I solved this problem locally by running this command
sudo npm cache clean
sudo npm install -g --unsafe-perm node-red
from node-red-docker.
I had the same issue with the docker image tagged "slim" running on a NUC and ubuntu (latest LTS) as host. None of the above suggested solutions worked for me.
As a workarround I switched to "latest" image which is of course a lot bigger, but provides the functionality via Environment (docker-compose.yaml).
from node-red-docker.
Hello.
Can you give the steps you used to change the timezone and how you attempted to verify it?
from node-red-docker.
Just an update in case anyone is in the same boat as me: For various reasons, I prefer to configure as much as I can within Synology's idiosyncratic docker GUI. @RaymondMouthaan solution works, but the GUI doesn't want to let you browse into that part of the file system to link the synology system files to the container's files.
My work around was to use SSH to symlink /etc/TZ and /etc/localtime into the folder where I keep my node-red config on my data volume. The GUI also doesn't want you to let you link to a symlink, so you'll want to create dummy files (eg "touch TZ"), configure the GUI to point to them, then after you save your config, you can just replace the dummy files with the symlinks, and everything works.
from node-red-docker.
@supagold does the symlink survive a restart?
I'm in the same boat. Would prefer a OOTB solution, like a TZ environment variable like most other containers use,
Since I can't PM you - were you able to launch the container with the data directory being able to map to a host folder correctly? I have to pass in the user property for the permission, but this redirects the storage folder. #70
from node-red-docker.
@jhelmink I actually didn't think to test that, but I just did a reboot this weekend. It all appears to be working fine. EG doing "cat TZ" on my symlink gives the same output as "cat /etc/TZ" on the host, then doing "cat /etc/timezone" in the container also gives the same output. Functionally, all my nodes still seem to be firing correctly.
I'm not 100% sure if I follow your question on the container data, but I map the data directory the same as my other containers and haven't been having any issues. FWIW, that might be because I don't use the Docker volume that DSM creates? All my docker data lives in a folder on my regular share volume.
from node-red-docker.
@supagold that makes sense, you won't have r/w permission issues if you're using the regular share perhaps. Because I'm using the default share the docker container doesn't have r/w permissions to the mapped folders. Instead I pass through the local user name, which solves this, but creates it's own issue in that the node data is no longer written to any of the mapped folders any more (goes to a user folder instead) which in turn means it doesn't survive container upgrades etc.
from node-red-docker.
FYI to anyone reading this thread. Manually adding a TZ environment variable via the Synology Docker UI and setting your timezone does actually work with the Node Red docker container.
@supagold FYI.
@jthomas I would consider this issue closed.
(Confirmed this by; running a Terminal window via the Synology Docker UI and running the 'date' command which returned UTC. Stopped the container. Manually added an Environment variable 'TZ' value 'Pacific/Auckland'. Restarted the container and ran the 'date' command again, now returns local time.)
from node-red-docker.
@jhelmink , I’m using QNAP’s Container Station, which is assume is similar. How exactly did you add a TZ environment variable to an existing docker/container ? Please could you explain the steps
from node-red-docker.
I also tried @iuripereira suggestions, but that did not work for me .
`[/] # docker run -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -e TZ=Europe/London
"docker run" requires at least 1 argument(s).
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container`
from node-red-docker.
@nodecentral Synology Docker has a UI section in the container config where you can add environment variables. You set the variable and the value. I'm not using the CLI. You can see it in one of the steps here; https://www.synology.com/en-global/knowledgebase/DSM/help/Docker/docker_container
from node-red-docker.
Hi @jhelmink , thanks for responding,
I’m on QNAP but there are a lot of simularities, following those instructions as a guide and checking the QNAP version, I can’t seem to be able to change any environment variables after a container is created.
It looks like I can do something to set the Timezone at the start , when I’m creating it , but as I’m past that, I’m going to have to try and find some that is CLI based.
Does anyone have any ideas ?
from node-red-docker.
Confirmed, at least for the x86 build, that '-TZ Linux/ZoneName' is sufficient to set the timezone correctly now. Did some research and it looked like the upstream Alpine images (gliderlabs/docker-alpine#136) had a bug around this where they only maintained the tzdata package for installs, but were removing everything (like the /usr/share/zoneinfo files) post distribution blob generation. It looks like they no longer blow that away, which lets the ENV variable work correctly without having to force linking an external copy of those files (the -v /etc/timezone mounts above).
Essentially, without those files it reads the ENV variable, but can't find a matching file in /usr/share/zoneinfo, so I think it falls back to UTC.
Ergo: An upstream issue that was fixed in the Alpine images.
from node-red-docker.
@nodecentral You might only be able to set variables during the creation process.
There are some things that cannot be edited after creation with Synology (though variables isn't one of them)
from node-red-docker.
Using the nodeRed v8 docker and TZ does not work (at least not in Synology GUI Docker). It just defaults to UTC even with the variable set.
I've verified that using TZ via the Synology Docker GUI with NRv8 does work, so I'm unsure what could be causing your implementation to not support this? Double check you've provided a valid value for TZ perhaps.
from node-red-docker.
Hi, running on nodered/node-red-docker:0.20.5-v10
, using -e TZ="Africa/Johannesburg"
in the docker run
command. I am running the docker on a RPi. When I log into the docker container with docker exec ...
, running date
give me SAST
, South African Standard Time.
So far so good. But, looking at events raised, to a node-red-dashboard, they are still reported in UTC.
I thought Node-RED would take the TZ of the docker host?
from node-red-docker.
Hi, I think my fault - using JSONata to transform the date, think I need to go look into it first. Command that I use is $substring($fromMillis($.timestamp),0,10),
- I think fromMillis
turns date to UTC.
from node-red-docker.
Node-RED 1.0.0 is now available on docker hub - https://hub.docker.com/r/nodered/node-red.
This closes this issue.
There are a few changes to the new release, please read the README for further details.
from node-red-docker.
Hello, on Synology NAS it's possible to use the Docker Application to pass the timezone automatically to the container creation.
Click in the “Environment” tab and add TZ in the variable & your timezone as the value.
You can follow this guide to see how can you do it.
https://www.atomicha.com/synology-nas-docker-installing-node-red-part-3-docker-image-configuration/
from node-red-docker.
I confirm that using the "TZ" environment variable seems to be the way to go. I always bind /etc/localtime & /etc/timezone, but that does not seem to work with Node-RED containers.
from node-red-docker.
Related Issues (20)
- ERROR [release 4/7] RUN npm config set python which python3 --global HOT 2
- Define niceness of the process - High priority HOT 1
- Docker images on the Hub are 9 months out of date / not regularly published even when there isn't a Node Red update HOT 21
- No matching manifest for windows/amd64 HOT 2
- NPM fails to install due to running node v14 instead of recommend v16 HOT 6
- TensorFlow nodes can't be installed due to Alpine image incompatibilty HOT 2
- ERROR: failed to solve: process "/bin/sh -c ./known_hosts.sh /etc/ssh/ssh_known_hosts && rm /usr/src/node-red/known_hosts.sh" HOT 8
- Getting errors trying to update Node-red-contrib-bigtimer and node-red-contrib-home-assistant-websocket HOT 13
- latest is actually -16, shouldn't it be -18? HOT 1
- Cannot load external flows for env var FLOWS=http... HOT 1
- Image with Debian and 18 HOT 8
- Crashing on RPi3 armv7l after latest build HOT 8
- docker pull 'missing signature key' HOT 4
- Support Node 20 HOT 4
- Problems accessing the ttyS2 HOT 5
- unhealthy state since v3.0.0 HOT 9
- Docker image with node 18.x core dumped HOT 12
- I'm not able to create mountpath: /data HOT 4
- Cannot install new nodes on fresh Docker image HOT 9
- Node-Red image v3.1.6-18 has CVE-2023-42282 vulnerability HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-red-docker.