Keeping the time correct on rancheros

I’m using the rancher docker host that gets delivered built in via freenas and I’m having trouble getting the time correct in rancheros. With some help from the guys over in the freenas forum I’ve got the time to be correct when the rancheros is started from BHYVE using the -u command line option on BHYVE, but after a while the time drifts in the rancheros. In my case it looses a few seconds per hour. If I ssh into rancheros and do a date command and do another on a container, they start off all OK, but then drift.

I’m just running the host by hand and using portainer as it is quite a small host.

Is there any documentation on running NTP or some such on the bear metal rancheros so that the time is kept up to date? I’ve tried searching, but no joy so far. No all the dockers I’d like to run have built in NTP servives, so I’d really liike to keep the time on the rancheros host correct.

Thanks in advance for any pointers.

What I’ve found so far is that the system container for NTP is trying to set the date correct but failing. If I stop that container and run ntp by hand, it updates the clock fine. Here are some logs; first the logs from ntp…

[rancher@rancher ~]$ sudo system-docker logs ntp

  • echo ‘starting in one shot mode to fix large time differences’
    starting in one shot mode to fix large time differences
  • ntpd -gq
    13 May 18:14:07 ntpd[11]: ntpd 4.2.8p10@1.3728-o Wed Jul 26 20:13:20 UTC 2017 (1): Starting
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    starting in one shot mode to fix large time differences
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    starting in one shot mode to fix large time differences
  • ntpd -gq
    13 May 18:14:07 ntpd[11]: ntpd 4.2.8p10@1.3728-o Wed Jul 26 20:13:20 UTC 2017 (1): Starting
    13 May 18:14:07 ntpd[11]: Command line: ntpd -gq
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    starting in one shot mode to fix large time differences
    [rancher@rancher ~]$ sudo system-docker logs ntp
  • echo ‘starting in one shot mode to fix large time differences’
    starting in one shot mode to fix large time differences
  • ntpd -gq

and it just loops round doing the same thing. Note the date on the logs is shown at 13 May, over 10 days out.

if I stop that system ntp and run things myself, we get and proper update and the date is correct.

rancher@rancher ~] sudo ntpd -d -n 24 May 05:38:16 ntpd[26584]: ntpd 4.2.8p10@1.3728-o Wed Jul 26 20:13:20 UTC 2017 (1): Starting 24 May 05:38:16 ntpd[26584]: Command line: ntpd -d -n 24 May 05:38:16 ntpd[26584]: proto: precision = 4000.250 usec (-8) 24 May 05:38:16 ntpd[26584]: proto: fuzz beneath 0.280 usec 24 May 05:38:16 ntpd[26584]: Listen and drop on 0 v6wildcard [::]:123 24 May 05:38:16 ntpd[26584]: Listen and drop on 1 v4wildcard 0.0.0.0:123 24 May 05:38:16 ntpd[26584]: Listen normally on 2 lo 127.0.0.1:123 24 May 05:38:16 ntpd[26584]: Listen normally on 3 eth0 10.13.0.101:123 24 May 05:38:16 ntpd[26584]: Listen normally on 4 eth1 192.168.18.113:123 24 May 05:38:16 ntpd[26584]: Listen normally on 5 docker0 172.17.0.1:123 24 May 05:38:16 ntpd[26584]: Listen normally on 6 lo [::1]:123 24 May 05:38:16 ntpd[26584]: Listen normally on 7 eth0 [2a00:1508:a0d:fe00:2a0:98ff:fe25:ca6f]:123 24 May 05:38:16 ntpd[26584]: Listen normally on 8 eth0 [fe80::2a0:98ff:fe25:ca6f%2]:123 24 May 05:38:16 ntpd[26584]: Listen normally on 9 eth1 [fe80::2a0:98ff:fe6c:7b93%3]:123 24 May 05:38:16 ntpd[26584]: Listen normally on 10 docker0 [fe80::42:a4ff:fe08:af3e%6]:123 24 May 05:38:16 ntpd[26584]: Listen normally on 11 veth3c89864 [fe80::988e:b0ff:feb0:ecdb%8]:123 24 May 05:38:16 ntpd[26584]: Listen normally on 12 veth767c584 [fe80::8833:f4ff:fea0:d42%11]:123 24 May 05:38:16 ntpd[26584]: Listening on routing socket on fd #29 for interface updates 24 May 05:38:41 ntpd[26584]: ntpd exiting on signal 2 (Interrupt) 24 May 05:38:41 ntpd[26584]: 203.118.151.32 local addr 10.13.0.101 -> <null> 24 May 05:38:41 ntpd[26584]: 122.252.188.99 local addr 10.13.0.101 -> <null> 24 May 05:38:41 ntpd[26584]: 130.217.226.51 local addr 10.13.0.101 -> <null> 24 May 05:38:41 ntpd[26584]: 202.78.240.38 local addr 10.13.0.101 -> <null> [rancher@rancher ~] date
Thu May 24 05:38:44 UTC 2018

It looks to me as though the ntp container just isn’t able to update the system time. Any thoughts on this appreciated. I’m running on OOTB rancheros 1.3 as supplied as part of FREENAS.