Skip to content

ntptime gives error in a container #16905

@ksasi

Description

@ksasi

Hi,

ntptime gives an error in the container as shown below :

root@ubuntu:/docker# docker run -it ntp_container /bin/bash
root@482b73de7a54:/# ps -ef|grep ntpd
root 17 1 0 08:35 ? 00:00:00 grep --color=auto ntpd
root@482b73de7a54:/# clear
root@482b73de7a54:/# ntptime
ntp_gettime() returns code 5 (ERROR)
time d9c34c6a.d35e4000 Sat, Oct 10 2015 8:35:54.825, (.825657),
maximum error 16000000 us, estimated error 16000000 us, TAI offset 0
ntp_adjtime() returns code 5 (ERROR)
modes 0x0 (),
offset 0.000 us, frequency 0.000 ppm, interval 1 s,
maximum error 16000000 us, estimated error 16000000 us,
status 0x40 (UNSYNC),
time constant 2, precision 1.000 us, tolerance 500 ppm,
root@482b73de7a54:/# ntpq -p
ntpq: read: Connection refused
root@482b73de7a54:/# sudo service ntp restart

  • Stopping NTP server ntpd [ OK ]
  • Starting NTP server ntpd [ OK ]
    root@482b73de7a54:/# ntpq -p
    remote refid st t when poll reach delay offset jitter

    172.82.134.51 152.2.133.54 2 u 2 64 1 50.172 -2.708 0.000
    ec2-107-22-169- 18.26.4.105 2 u 1 64 1 70.422 5.155 0.000
    ntp.wdc1.us.lea .INIT. 16 u - 64 0 0.000 0.000 0.000
    time-a.nist.gov .INIT. 16 u - 64 0 0.000 0.000 0.000
    golem.canonical .INIT. 16 u - 64 0 0.000 0.000 0.000
    root@482b73de7a54:/# ntptime
    ntp_gettime() returns code 5 (ERROR)
    time d9c34c81.fcdb2000 Sat, Oct 10 2015 8:36:17.987, (.987719),
    maximum error 16000000 us, estimated error 16000000 us, TAI offset 0
    ntp_adjtime() returns code 5 (ERROR)
    modes 0x0 (),
    offset 0.000 us, frequency 0.000 ppm, interval 1 s,
    maximum error 16000000 us, estimated error 16000000 us,
    status 0x40 (UNSYNC),
    time constant 2, precision 1.000 us, tolerance 500 ppm,
    root@482b73de7a54:/#

The host running the container doesn't have NTP installed. Below is the docker file:

root@ubuntu:/docker# more Dockerfile

Set the base image :

FROM ubuntu:trusty

File Author/Maintainer :

MAINTAINER Sasikanth Kotti [email protected]

USER root

ENV LANG en_US.UTF-8

ntp

RUN sudo apt-get clean
RUN sudo apt-get update
RUN sudo apt-get -f install -y libsasl2.2 ntp lsb psutils

However ntptime works fine if NTP is installed on the host. Below are the details :

root@ubuntu:/docker# sudo apt-get install ntp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.19.0-28 linux-headers-3.19.0-28-generic
linux-image-3.19.0-28-generic linux-image-extra-3.19.0-28-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libopts25
Suggested packages:
ntp-doc
The following NEW packages will be installed:
libopts25 ntp
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/473 kB of archives.
After this operation, 1,676 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Selecting previously unselected package libopts25:amd64.
(Reading database ... 96669 files and directories currently installed.)
Preparing to unpack .../libopts25_1%3a5.18-2ubuntu2_amd64.deb ...
Unpacking libopts25:amd64 (1:5.18-2ubuntu2) ...
Selecting previously unselected package ntp.
Preparing to unpack .../ntp_1%3a4.2.6.p5+dfsg-3ubuntu2.14.04.3_amd64.deb ...
Unpacking ntp (1:4.2.6.p5+dfsg-3ubuntu2.14.04.3) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Setting up libopts25:amd64 (1:5.18-2ubuntu2) ...
Setting up ntp (1:4.2.6.p5+dfsg-3ubuntu2.14.04.3) ...

  • Starting NTP server ntpd [ OK ]
    Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
    root@ubuntu:/docker# docker run -it ntp_container /bin/bash
    root@0641755070a5:/# ps -ef|grep ntpd
    root 16 1 0 08:42 ? 00:00:00 grep --color=auto ntpd
    root@0641755070a5:/# ntptime
    ntp_gettime() returns code 0 (OK)
    time d9c34de6.60f3a000 Sat, Oct 10 2015 8:42:14.378, (.378717),
    maximum error 18516 us, estimated error 16 us, TAI offset 0
    ntp_adjtime() returns code 0 (OK)
    modes 0x0 (),
    offset 0.000 us, frequency 219.804 ppm, interval 1 s,
    maximum error 18516 us, estimated error 16 us,
    status 0x1 (PLL),
    time constant 7, precision 1.000 us, tolerance 500 ppm,
    root@0641755070a5:/# ntpq -p
    ntpq: read: Connection refused
    root@0641755070a5:/# sudo service ntp restart
  • Stopping NTP server ntpd [ OK ]
  • Starting NTP server ntpd [ OK ]
    root@0641755070a5:/# ntpq -p
    remote refid st t when poll reach delay offset jitter

    104.41.150.68 129.6.15.30 2 u 6 64 1 69.129 -38.422 0.000
    soft-sea-01.ser .INIT. 16 u - 64 0 0.000 0.000 0.000
    206.51.211.152 206.51.211.153 4 u 5 64 1 75.153 -20.886 0.000
    216.152.240.220 164.67.62.194 2 u 4 64 1 67.885 -87.027 0.000
    golem.canonical 193.79.237.14 2 u 3 64 1 155.732 -28.138 0.000
    root@0641755070a5:/# ntptime
    ntp_gettime() returns code 0 (OK)
    time d9c34e31.f103e000 Sat, Oct 10 2015 8:43:29.941, (.941465),
    maximum error 56016 us, estimated error 16 us, TAI offset 0
    ntp_adjtime() returns code 0 (OK)
    modes 0x0 (),
    offset 0.000 us, frequency 219.804 ppm, interval 1 s,
    maximum error 56016 us, estimated error 16 us,
    status 0x1 (PLL),
    time constant 7, precision 1.000 us, tolerance 500 ppm,
    root@0641755070a5:/#

Please advise on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions