大网数据广告活动
服务器运维问答

Docker container time 2 hours behind when TZ=CEST

· 52CE 我爱测

I try to run a Docker container with the same timezone as my Docker host. The host timezone is CEST . When I run : $ date Thu Apr 16 11:04:11 CEST 2020 $ docker run -e TZ=CEST debian:buster date Thu Apr 16 09:04:14 CEST 2020 The …

问题原文

原帖链接 · Eric Citaire · CC BY-SA 4.0

I try to run a Docker container with the same timezone as my Docker host. The host timezone is CEST.

When I run :

$ date
Thu Apr 16 11:04:11 CEST 2020
$ docker run -e TZ=CEST debian:buster date
Thu Apr 16 09:04:14 CEST 2020

The container is 2 hours behind the host.

On the other hand, if I set TZ=Europe/Paris, it works as expected :

$ docker run -e TZ=Europe/Paris debian:buster date
Thu Apr 16 11:04:22 CEST 2020

Is this a bug or am I missing something?

已采纳解答

原帖链接 · Eric Citaire · CC BY-SA 4.0

After some research, it appears that CEST is not a valid value for TZ environment variable. CEST is just a displayable version of CET when the current date is summer.

In fact, if I set TZ to an obviously invalid value, it gives :

$ TZ=FOO date
Fri Apr 17 14:07:56 FOO 2020

Also note that it has nothing to do with Docker.

References :

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-04-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。