Answer the question
In order to leave comments, you need to log in
How to make timestamp on localhost match timestamp in docker?
On localhost and in docker, the time differs by 3 hours, in docker it lags behind
[email protected]:/# cat /etc/timezone
Europe/Moscow
[email protected]:/# exit
exit
[email protected]:~$ cat /etc/timezone
Europe/Moscow
ENV TZ=Europe/Moscow
RUN apt-get install -y tzdata
RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Answer the question
In order to leave comments, you need to log in
umvr
Dockerfile
FROM ubuntu
ENV TZ=Europe/Moscow
RUN apt-get update && apt-get install -yy tzdata
RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu
---> d70eaf7277ea
Step 2/4 : ENV TZ=Europe/Moscow
---> Using cache
---> 24c7e693dacf
Step 3/4 : RUN apt-get update && apt-get install -yy tzdata
---> Using cache
---> 8d1bbd58900b
Step 4/4 : RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
---> Using cache
---> b65965107725
Successfully built b65965107725
$ docker run b65965107725 date
Thu Oct 29 21:09:13 MSK 2020
$ date
Thu Oct 29 21:09:15 MSK 2020
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question