sunny03 发表于 2018-5-28 09:40:14

关于docker 容器中的时间同步

  故障原因:(centos6.6)
  在docker容器中安装ntpdate时间同步

  #yum -y install ntpdate
  bash-4.1# ntpdate s1a.time.edu.cn
22 Dec 14:41:16 ntpdate: step-systime: Operation not permitted
  提示无法更改系统时间。
  

  排除问题过程

[*]  ping s1a.time.edu.cn

[*]  百度,step-systime: Operation not permitted 。没有找到答案
[*]  百度 docker 容器 不能同步时间
  百度答案 -v /etc/localtime:/etc/localtime:ro
  docker -d -it -v /etc/localtime:/etc/localtime:ro --name test centos:6.6 /bin/bash
[*]  宿主机运行ntpdate
  ntpdate s1a.time.edu.cn
[*]  更改宿主机任务计划
  crontab -e
*/5 * * * * /usr/sbin/ntpdate s1a.time.edu.cn &> /dev/null
  
  测试
      容器时间

      docker exec -it test /bin/bash
      # date
    Fri Mar3 14:00:29 CST 2017
   宿主机时间

      # date
    Fri Mar3 14:00:50 CST 2017


  
页: [1]
查看完整版本: 关于docker 容器中的时间同步