在docker中重新配置时区不工作

时间:2016-12-02 01:56:02

标签: linux ubuntu docker timezone

首先,我在我的Dockerfile中配置时区,如下所示,但它失败了(因为我进入docker容器并执行'date',只获得Etc / UTC时间。)

   FROM selenium/standalone-firefox:3.0.1-aluminum
   USER root
   RUN echo "Asia/Shanghai" > /etc/timezone
   RUN dpkg-reconfigure -f noninteractive tzdata

然后,我再次尝试如下,似乎'dpkg-reconfigure'重置/ etc / timezone。那么地球上有什么问题?

enter image description here

补编: 在我按照BMitch建议的方法执行后,它确实向前迈出了一步,但又出现了另一个令人困惑的问题:docker容器内的date命令打印错误的时间。 enter image description here

1 个答案:

答案 0 :(得分:2)

Selenium将他们的图像基于Ubuntu,Ubuntu从标准的Debian方法改变了非交互式tzdata重新配置的行为。请改用以下内容:

FROM selenium/standalone-firefox:3.0.1-aluminum
USER root
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
 && dpkg-reconfigure -f noninteractive tzdata

有关详细信息,请参阅this bug report