Reputation: 4618
The time inside my container is 1.5 hours behind UTC/GMT. And I think I'm misunderstanding what i should be changing.
In the container, i run the following commands, which result in the container telling me that it's running in UTC. But the container UTC seems different to what I know as UTC.
root@1166f2f648d3:/app# cat /etc/timezone
Etc/GMT
root@1166f2f648d3:/app# date +"%Z %z"
UTC +0000
root@1166f2f648d3:/app# date
Mon Jul 27 07:08:09 UTC 2020 (Should be 9:38 UTC)
I tried copying a file to /etc/timezone containing Etc/GMT
, which replaced the original value of Etc/UTC
but this seems to have had no effect.
I also tried adding this to my Dockerfile just to see if there was any change at all, with no effect:
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Background info: I'm running Linux docker containers from Windows 10, testing datetimes with redis.
My question is, how do i make it so the container date/time is the same as the result from https://www.google.co.uk/search?q=utc+time
Upvotes: 0
Views: 4929
Reputation: 60016
The Googe link show UTC
time, so I think you need UTC
time. instead of America/Los_Angeles
ENV TZ="UTC"
RUN date
Not sure about your base image so you can try this
FROM alpine
RUN apk add --no-cache tzdata
ENV TZ="UTC"
RUN date
output
Step 3/4 : ENV TZ="UTC"
---> Running in fba71f2eea2a
Removing intermediate container fba71f2eea2a
---> e27e60387908
Step 4/4 : RUN date
---> Running in a9e8e7260d2b
Mon Jul 27 09:45:17 UTC 2020
Upvotes: 2