Skip to content

Instantly share code, notes, and snippets.

@lmmsoft
Created February 21, 2020 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmmsoft/c4b7f02675f381f9fc8c9075c61a4d8f to your computer and use it in GitHub Desktop.
Save lmmsoft/c4b7f02675f381f9fc8c9075c61a4d8f to your computer and use it in GitHub Desktop.
Dockerfile 使用北京时间
# Dockerfile 使用北京时间
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
# or
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
# 1、CentOS6、Ubuntu16
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 2、CentOS7、RHEL7、Scientific Linux 7、Oracle Linux 7 最好的方法是使用timedatectl命令
timedatectl list-timezones |grep Shanghai #查找中国时区的完整名称
Asia/Shanghai
timedatectl set-timezone Asia/Shanghai #其他时区以此类推
# 3、直接手动创建软链接
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment