Closed jorgemoralespou closed 7 years ago
What kinds of logs is the problem here and how do i access them?
Any logs. If you log into a container and do time, and you do time outside the container in your host, you'll get different TimeZone, so basically when you do a build (as an example) and then you see the logs, the time you'll see is not what you would expect.
There's a way to pass env variables to the container when it starts, and I think that all we need to do is set TZ='whateverTZ_you_are', for example, in my case would be, TZ='Europe/Madrid'
With TZ set:
[jmorales@mac-santander ~] $date
Sat Oct 15 22:55:36 CEST 2016
[jmorales@mac-santander ~] $oc-cluster ssh
Going into the Origin Container
[root@moby origin]# date
Sat Oct 15 22:55:41 CEST 2016
Without TZ set:
[jmorales@mac-santander ~] $date
Sat Oct 15 22:57:12 CEST 2016
[jmorales@mac-santander ~] $oc-cluster ssh
Going into the Origin Container
[root@moby origin]# date
Sat Oct 15 20:57:17 UTC 2016
Ideally, we should get TZ from the host the cluster is running, and letting override by user if they want.
If we just want the correct time when connecting to origin we could always do
docker exec -it origin /bin/bash -c "export TZ='Europe/Oslo' && /bin/bash"
We could find the tz this way. From http://stackoverflow.com/questions/12521114/getting-the-canonical-time-zone-name-in-shell-script
if [ -f /etc/timezone ]; then
OLSONTZ=cat /etc/timezone
elif [ -h /etc/localtime ]; then
OLSONTZ=readlink /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///"
else
checksum=md5sum /etc/localtime | cut -d' ' -f1
OLSONTZ=find /usr/share/zoneinfo/ -type f -exec md5sum {} \; | grep "^$checksum" | sed "s/.*\/usr\/share\/zoneinfo\///" | head -n 1
fi
echo $OLSONTZ
Fixed
So that logs display the same way as your hosts time.