Docker中修改时区

在Docker中运行关于时间的代码发现总是出现特别奇怪的问题,比如:应该白天出现的时间总是显示在半夜。通过命令date发现,时区不是当前所在时区。查阅资料后,一个适合自己的时区修改方式如下:

dpkg-reconfigure tzdata

初始时大概会报错:需要安装tzdata安装包 

/usr/sbin/dpkg-reconfigure: tzdata is not installed

安装之后,便可以根据提示,选择自己想要设置的时区。比如我选择北京时间(上海):

Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time
zones in which they are located.

  1. Africa  2. America  3. Antarctica  4. Australia  5. Arctic  6. Asia  7. Atlantic  8. Europe  9. Indian  10. Pacific  11. SystemV  12. US  13. Etc
Please select the city or region corresponding to your time zone.

  1. Aden      11. Baku        21. Damascus     31. Hong_Kong  41. Kashgar       5
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值