1、进入docker
docker exec d7f -it /bin/bash //d7f 是容器的id或名称,我这里是id
2、查看时区
dpkg-reconfigure tzdata
Current default time zone: 'Etc/UTC'
Local time is now: Sat Jan 30 06:33:32 UTC 2021.
Universal Time is now: Sat Jan 30 06:33:32 UTC 2021.
3、Linux 修改本机时间
旧版本(如CentOS6)
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
新版本(如CentOS7)
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
4、重启docker
5、验证时区
dpkg-reconfigure tzdata
Current default time zone: 'Asia/Shanghai'
Local time is now: Sat Jan 30 14:47:16 CST 2021.
Universal Time is now: Sat Jan 30 06:47:16 UTC 2021.