docker - 所有 docker 容器的默认时区

标签 docker

我使用的是 Ubuntu 操作系统。使用下面的命令我可以查看创建容器的日期和时间。

$ docker inspect httpd | grep Created
  Created": "2019-09-22T05:46:42.109648817Z",

我可以使用下面的命令查看我的本地系统时区

$ cat /etc/timezone 
Asia/Kolkata

如您所见,我的系统时区设置为 Asia/Kolkata 但使用 dockerspect 命令显示的时间似乎是 UTC。

我还使用以下命令将系统时区重新配置为亚洲/加尔各答:

$ sudo dpkg-reconfigure tzdata
Current default time zone: 'Asia/Kolkata'
Local time is now:      Sun Sep 22 11:27:05 IST 2019.
Universal Time is now:  Sun Sep 22 05:57:05 UTC 2019.

当我创建一个新容器时,它的创建时间仍以 UTC 格式显示。

如何配置我的系统,以便对于任何现有或新创建的容器,创建时间都按照我的系统时区设置显示。

最佳答案

您可以尝试 docker run 命令中的 TZ 选项 喜欢

docker run -rm -e TZ=Europe/Bucharest -it myimage

这将在 docker 容器内分配您想要的时区

关于docker - 所有 docker 容器的默认时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58046483/

相关文章:

php - 修改数据卷中的文件后添加了非法 token

docker - 如何使用花来监控1个以上的 worker

c# - 环境变量更改时重新加载配置

docker - 无法在 gitlab CI 中构建 docker 镜像

docker - Win10 Docker安装AzerothCore无法构建authserver和worldserver

docker - 从 docker inspect 获取标签值

docker - 什么 Docker 镜像大小被认为是 'too large' ?

python - Django/Celery - AttributeError : module 'novopagemento' has no attribute 'celery'

mongodb - 将数据容器的卷映射到卷

docker - CentOS 8 Docker 容器中的 who 和 w 命令