如何更改正在运行泊坞窗私人注册表容器的时区/时间
主机操作系统:CentOS 7 Docker版本:
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:42:49 2017
OS/Arch: linux/amd64
Experimental: false
Docker注册表图片:registry:2 ID: a07e3f32a779
尝试在容器上执行:
export TZ=Europe/Warsaw
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
但没有任何实时结果。
相同的解决方案适用于其他容器而没有任何问题。
任何想法?
修改
使用以下内容撰写的重新创建的容器:
apache:
image: "httpd:2.4"
hostname: deleted
restart: always
environment:
- TZ=Europe/Warsaw
ports:
- 5043:5043
links:
- registry:registry
volumes:
- /opt/docker-registry-bundle/auth:/usr/local/apache2/conf
- /etc/timezone:/etc/timezone:ro
registry:
image: registry:2
restart: always
environment:
- TZ=Europe/Warsaw
ports:
- 127.0.0.1:5000:5000
volumes:
- /opt/docker-registry-bundle/registry-data:/var/lib/registry
- /etc/timezone:/etc/timezone:ro
在apache容器上时间没问题。 在注册表容器上仍然无法正常工作。
答案 0 :(得分:0)
在容器内执行时,以下内容应该有效:
echo "Europe/Warsaw" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
答案 1 :(得分:0)
解决方案
注册表:由于该dpkg命令,2图像使用高山基本图像 缺少,请参阅下面的链接,该链接解释了如何更改时区 基于高山的图像。 ivankrizsan.se/2015/10/31/time-in-docker-containers(参见Alpine Linux 部分)