1. 安装ntp ntpdate包,同步系统时间
yum install -y ntp ntpdate
ntpdate 0.asia.pool.ntp.org
然后使用date命令,查看系统时间是否同步
2. 同步系统时间到docker容器
这里示例同步php和nginx两个容器
docker cp /usr/share/zoneinfo/Asia/Shanghai php:/etc/localtime
docker cp /usr/share/zoneinfo/Asia/Shanghai nginx:/etc/localtime
先重启容器,然后进入容器使用date命令,查看时间是否同步
docker restart php
docker restart nginx
docker exec -it php bash
网友评论