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

Docker - Timezones in containers not same as on host

· 52CE 我爱测

In all my running docker containers the containers system time is set to UTC whereas on my host (debian) its CEST. Why dont they sync automaticly? How do i make them set the right time when bringing them up? root@v220151068062892…

问题原文

原帖链接 · haemse · CC BY-SA 3.0

In all my running docker containers the containers system time is set to UTC whereas on my host (debian) its CEST.

Why dont they sync automaticly? How do i make them set the right time when bringing them up?

root@v2201510680628925:/home/jacob# docker version
Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:36:47 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:36:47 2016
 OS/Arch:      linux/amd64
root@v2201510680628925:/home/jacob# date
Wed Aug  2 09:59:20 CEST 2017
root@v2201510680628925:/home/jacob# docker exec -it naos_nginx bash
root@0cefa7f7096c:/# date
Wed Aug  2 07:59:34 UTC 2017
root@0cefa7f7096c:/# exit
exit
root@v2201510680628925:/home/jacob# docker exec -it ah_avail bash
root@da52e8f3f61f:/usr/src/app# date
Wed Aug  2 07:59:59 UTC 2017
root@da52e8f3f61f:/usr/src/app# exit
exit
root@v2201510680628925:/home/jacob#

社区高分解答

原帖链接 · Alexandre Roux · CC BY-SA 3.0

You should be able to set timezone in your containers by using tzdata :

docker run -e TZ=Europe/Amsterdam debian:jessie date

Credits and further explanation to "Why containers don't sync time with host" : Docker Container time & timezone (will not reflect changes)

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

资料来源与适用范围

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

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

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