故障原因:(centos6.6)

在docker容器中安装ntpdate时间同步

#yum -y install ntpdate

bash-4.1# ntpdate s1a.time.edu.cn
22 Dec 14:41:16 ntpdate[31]: step-systime: Operation not permitted

提示无法更改系统时间。


排除问题过程

  1. ping s1a.time.edu.cn

  2. 百度,step-systime: Operation not permitted 。没有找到答案

  3. 百度 docker 容器 不能同步时间

    百度答案 -v /etc/localtime:/etc/localtime:ro

    docker -d -it -v /etc/localtime:/etc/localtime:ro --name test centos:6.6 /bin/bash

  4. 宿主机运行ntpdate

    ntpdate s1a.time.edu.cn

  5. 更改宿主机任务计划

    crontab -e
    */5 * * * * /usr/sbin/ntpdate s1a.time.edu.cn &> /dev/null

测试

    容器时间

    docker exec -it test /bin/bash

    [root@d2629ea7c6bc /]# date
    Fri Mar  3 14:00:29 CST 2017

   宿主机时间

    [root@localhost ~]# date
    Fri Mar  3 14:00:50 CST 2017