Git Product home page Git Product logo

docker-ntp's Introduction

About this container

Docker Pulls Docker Stars GitHub Stars Apache licensed

This container runs chrony on Alpine Linux.

chrony is a versatile implementation of the Network Time Protocol (NTP). It can synchronise the system clock with NTP servers, reference clocks (e.g. GPS receiver), and manual input using wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) server and peer to provide a time service to other computers in the network.

Supported Architectures

Architectures officially supported by this Docker container. Simply pulling this container from Docker Hub should retrieve the correct image for your architecture.

Linux x86-64 ARMv8 64-bit IBM POWER8 IBM Z Systems Linux x86/i686 ARMv7 32-bit ARMv6 32-bit

How to Run this container

With the Docker CLI

Pull and run -- it's this simple.

# pull from docker hub
$> docker pull cturra/ntp

# run ntp
$> docker run --name=ntp            \
              --restart=always      \
              --detach              \
              --publish=123:123/udp \
              cturra/ntp

# OR run ntp with higher security
$> docker run --name=ntp                           \
              --restart=always                     \
              --detach                             \
              --publish=123:123/udp                \
              --read-only                          \
              --tmpfs=/etc/chrony:rw,mode=1750     \
              --tmpfs=/run/chrony:rw,mode=1750     \
              --tmpfs=/var/lib/chrony:rw,mode=1750 \
              cturra/ntp

With Docker Compose

Using the docker-compose.yml file included in this git repo, you can build the container yourself (should you choose to). *Note: this docker-compose files uses the 3.9 compose format, which requires Docker Engine release 19.03.0+

# run ntp
$> docker compose up -d ntp

# (optional) check the ntp logs
$> docker compose logs ntp

With Docker Swarm

(These instructions assume you already have a swarm)

# deploy ntp stack to the swarm
$> docker stack deploy -c docker-compose.yml cturra

# check that service is running
$> docker stack services cturra

# (optional) view the ntp logs
$> docker service logs -f cturra_ntp

From a Local command line

Using the vars file in this git repo, you can update any of the variables to reflect your environment. Once updated, simply execute the build then run scripts.

# build ntp
$> ./build.sh

# run ntp
$> ./run.sh

Configure NTP Servers

By default, this container uses CloudFlare's time server (time.cloudflare.com). If you'd like to use one or more different NTP server(s), you can pass this container an NTP_SERVERS environment variable. This can be done by updating the vars, docker-compose.yml files or manually passing --env=NTP_SERVERS="..." to docker run.

Below are some examples of how to configure common NTP Servers.

Do note, to configure more than one server, you must use a comma delimited list WITHOUT spaces.

# (default) cloudflare
NTP_SERVERS="time.cloudflare.com"

# google
NTP_SERVERS="time1.google.com,time2.google.com,time3.google.com,time4.google.com"

# alibaba
NTP_SERVERS="ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com"

# local (offline)
NTP_SERVERS="127.127.1.1"

If you're interested in a public list of stratum 1 servers, you can have a look at the following list. Do make sure to verify the ntp server is active as this list does appaer to have some no longer active servers.

Chronyd Options

No Client Log (noclientlog)

This is optional and not enabled by default. If you provide the NOCLIENTLOG=true envivonrment variable, chrony will be configured to:

Specifies that client accesses are not to be logged. Normally they are logged, allowing statistics to be reported using the clients command in chronyc. This option also effectively disables server support for the NTP interleaved mode.

Logging

By default, this project logs informational messages to stdout, which can be helpful when running the ntp service. If you'd like to change the level of log verbosity, pass the LOG_LEVEL environment variable to the container, specifying the level (#) when you first start it. This option matches the chrony -L option, which support the following levels can to specified: 0 (informational), 1 (warning), 2 (non-fatal error), and 3 (fatal error).

Feel free to check out the project documentation for more information at:

Setting your timezone

By default the UTC timezone is used, however if you'd like to adjust your NTP server to be running in your local timezone, all you need to do is provide a TZ environment variable following the standard TZ data format. As an example, using docker-compose.yaml, that would look like this if you were located in Vancouver, Canada:

  ...
  environment:
    - TZ=America/Vancouver
    ...

Enable Network Time Security

If all the NTP_SERVERS you have configured support NTS (Network Time Security) you can pass the ENABLE_NTS=true option to the container to enable it. As an example, using docker-compose.yaml, that would look like this:

  ...
  environment:
    - NTP_SERVER=time.cloudflare.com
    - ENABLE_NTS=true
    ...

If any of the NTP_SERVERS you have configured does not support NTS, you will see a message like the following during startup:

NTS-KE session with 164.67.62.194:4460 (tick.ucla.edu) timed out

Testing your NTP Container

From any machine that has ntpdate you can query your new NTP container with the follow command:

$> ntpdate -q <DOCKER_HOST_IP>

Here is a sample output from my environment:

$> ntpdate -q 10.13.13.9
server 10.13.1.109, stratum 4, offset 0.000642, delay 0.02805
14 Mar 19:21:29 ntpdate[26834]: adjust time server 10.13.13.109 offset 0.000642 sec

If you see a message, like the following, it's likely the clock is not yet synchronized. You should see this go away if you wait a bit longer and query again.

$> ntpdate -q 10.13.13.9
server 10.13.13.9, stratum 16, offset 0.005689, delay 0.02837
11 Dec 09:47:53 ntpdate[26030]: no server suitable for synchronization found

To see details on the ntp status of your container, you can check with the command below on your docker host:

$> docker exec ntp chronyc tracking
Reference ID    : D8EF2300 (time1.google.com)
Stratum         : 2
Ref time (UTC)  : Sun Mar 15 04:33:30 2020
System time     : 0.000054161 seconds slow of NTP time
Last offset     : -0.000015060 seconds
RMS offset      : 0.000206534 seconds
Frequency       : 5.626 ppm fast
Residual freq   : -0.001 ppm
Skew            : 0.118 ppm
Root delay      : 0.022015510 seconds
Root dispersion : 0.001476757 seconds
Update interval : 1025.2 seconds
Leap status     : Normal

Here is how you can see a peer list to verify the state of each ntp source configured:

$> docker exec ntp chronyc sources
210 Number of sources = 2
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ time.cloudflare.com           3  10   377   404   -623us[ -623us] +/-   24ms
^* time1.google.com              1  10   377  1023   +259us[ +244us] +/-   11ms

Finally, if you'd like to see statistics about the collected measurements of each ntp source configured:

$> docker exec ntp chronyc sourcestats
210 Number of sources = 2
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
time.cloudflare.com        35  18  139m     +0.014      0.141   -662us   530us
time1.google.com           33  13  128m     -0.007      0.138   +318us   460us

Are you seeing messages like these and wondering what is going on?

$ docker logs -f ntps
[...]
2021-05-25T18:41:40Z System clock wrong by -2.535004 seconds
2021-05-25T18:41:40Z Could not step system clock
2021-05-25T18:42:47Z System clock wrong by -2.541034 seconds
2021-05-25T18:42:47Z Could not step system clock

Good question! Since chronyd is running with the -x flag, it will not try to control the system (container host) clock. This of course is necessary because the process does not have priviledge (for good reason) to modify the clock on the system.

Like any host on your network, simply use your preferred ntp client to pull the time from the running ntp container on your container host.


Buy Me A Coffee

docker-ntp's People

Contributors

adriadam10 avatar clementperon avatar cturra avatar fanonwue avatar ggovindan avatar kimdre avatar microbug avatar monster-echo avatar simonrupf avatar stumpylog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-ntp's Issues

comma seprate not working

"""
version: '3.4'

services:
ntp:
build: .
image: cturra/ntp:latest
container_name: ntp
restart: always
ports:
- 123:123/udp
cap_add:
- SYS_NICE
- SYS_RESOURCE
- SYS_TIME
environment:
- NTP_SERVERS="ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com,ntp5.aliyun.com,ntp6.aliyun.com,ntp7.aliyun.com"
"""
after cmd "docker exec ntp ntpctl -s all" the result shows
"""
0/1 peers valid, clock unsynced, clock offset is -22145.517ms

peer
wt tl st next poll offset delay jitter
not resolved ntp1.aliyun.comserver ntp2.aliyun.comserver ntp3.aliyun.comserver
1 2 - 14s 15s ---- peer not valid ----
"""

vars "NTP_SERVERS" not working

here is my docker-compose.yml file content
`
version: '3.4'

services:
ntp:
image: cturra/ntp:latest
container_name: ntp
restart: always
ports:
- 123:123/udp
cap_add:
- SYS_NICE
- SYS_RESOURCE
- SYS_TIME
environment:
- NTP_SERVERS="time.pool.aliyun.com"
`
the clock was not synced. so i checked the ntp peers and found the server name was "time*.google.com", clearly the var(NTP_SERVERS) was not setted gracefully.

no server suitable for synchronization found

Herro.

Nice repo, want to use for my NOTnet and to keep the google IOT to spam google.ntp all the time
Got this container up and running about a week and can't get the server to synq.

I do this:
ntp:
image: cturra/ntp:latest
container_name: ntp
restart: always
ports:
- 123:123
links:
- pihole
environment:
- NTP_SERVERS=time.cloudflare.com
- LOG_LEVEL=0

And open ufw 123/udp so my whole network can use this.

Doing some commands to check if it functions according to readme
Been trying this through my ISP and ovpn with no luck.

->

$ ntpdate -q 127.0.0.1
23 Nov 18:11:18 ntpdate[17102]: no server suitable for synchronization found

$ docker exec ntp chronyc tracking
Reference ID : 00000000 ()
Stratum : 0
Ref time (UTC) : Thu Jan 01 00:00:00 1970
System time : 0.000000000 seconds fast of NTP time
Last offset : +0.000000000 seconds
RMS offset : 0.000000000 seconds
Frequency : 0.000 ppm slow
Residual freq : +0.000 ppm
Skew : 0.000 ppm
Root delay : 1.000000000 seconds
Root dispersion : 1.000000000 seconds
Update interval : 0.0 seconds
Leap status : Not synchronised

$ docker exec ntp chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================
why is this emty ? :/

$ docker logs -f ntp
2022-11-23T16:57:59Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-11-23T16:57:59Z Disabled control of system clock
2022-11-23T16:57:59Z Could not read valid frequency and skew from driftfile /var/lib/chrony/chrony.drift

NTP Servers with local not working

  • local NTP_SERVERS :
--env=NTP_SERVERS="127.127.1.1"
// if [[ "${N_CLEANED}" == "127\."* ]]  is false 
// if [[ "${N_CLEANED}" == "127."* ]]   is true 

if [[ "${N_CLEANED}" == "127\."* ]]; then 
    echo "server "${N_CLEANED} >> ${CHRONY_CONF_FILE}
    echo "local stratum 10"    >> ${CHRONY_CONF_FILE}

  # found external time servers
  else
    echo "server "${N_CLEANED}" iburst" >> ${CHRONY_CONF_FILE}
  fi

is it a bug ?

What does this ntp set the time of?

So typically you run ntp to set the time of the computer. So does running this in a container affect the time of the docker host, or the other containers?

If not what is the use case for this, as a ntp relay?

Repeated Wrong Perms on /var/run/chrony

Seems to be working, but I do see perm issue a lot in the log. Running in Docker on a RPi4 and an Intel Nuc not with the 'higher security option. Log is pulled from the rpi4, similar on the nuc. Volumes: /var/lib/chrony /etc/chrony /run/chrony Build: cturra/docker-ntp build-date:- 2022-02-27T03:59:53+0000

Thanks! And thanks for the docker image!

2022-07-06T01:54:05Z Wrong permissions on /var/run/chrony
2022-07-06T01:54:05Z Disabled command socket /var/run/chrony/chronyd.sock
2022-07-06T01:54:05Z Disabled control of system clock
2022-07-06T01:54:11Z Selected source 69.89.207.99 (0.north-america.pool.ntp.org)
2022-07-06T01:54:58Z chronyd exiting
2022-07-06T01:55:05Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-07-06T01:55:05Z Wrong permissions on /var/run/chrony
2022-07-06T01:55:05Z Disabled command socket /var/run/chrony/chronyd.sock
2022-07-06T01:55:05Z Disabled control of system clock
2022-07-06T01:55:10Z Selected source 142.147.88.111 (2.north-america.pool.ntp.org)
2022-07-06T01:55:11Z Selected source 192.5.41.209 (ntp2.usno.navy.mil)
2022-07-06T02:45:40Z chronyd exiting
2022-07-06T02:45:56Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-07-06T02:45:56Z Wrong permissions on /var/run/chrony
2022-07-06T02:45:56Z Disabled command socket /var/run/chrony/chronyd.sock
2022-07-06T02:45:56Z Disabled control of system clock
2022-07-06T02:47:34Z Forward time jump detected!
2022-07-06T02:47:40Z Selected source 192.5.41.209 (ntp2.usno.navy.mil)
2022-07-10T07:24:52Z Source 68.171.16.4 replaced with 45.32.207.136 (0.north-america.pool.ntp.org)
2022-07-12T15:41:16Z chronyd exiting
2022-07-12T15:41:32Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-07-12T15:41:32Z Wrong permissions on /var/run/chrony
2022-07-12T15:41:32Z Disabled command socket /var/run/chrony/chronyd.sock
2022-07-12T15:41:32Z Disabled control of system clock
2022-07-12T15:43:07Z Selected source 192.5.41.209 (ntp2.usno.navy.mil)
2022-07-12T15:44:20Z Source 129.146.64.32 replaced with 72.14.183.239 (0.north-america.pool.ntp.org)
2022-07-19T14:33:34Z chronyd exiting
2022-07-19T14:33:51Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-07-19T14:33:51Z Wrong permissions on /var/run/chrony
2022-07-19T14:33:51Z Disabled command socket /var/run/chrony/chronyd.sock
2022-07-19T14:33:51Z Disabled control of system clock
2022-07-19T14:35:30Z Forward time jump detected!
2022-07-19T14:35:36Z Selected source 192.5.41.209 (ntp2.usno.navy.mil)

Latest updates broke ntp on Raspberry Pi

Hi,
I'm running your ntp Docker container on a Raspberry Pi, and the last update seems to have broken it.

Here are my logs:

ntp              | +588592596-05-04T01:24:56Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS -NTS -SECHASH +IPV6 -DEBUG)
ntp              | +588384768-06-10T08:00:24Z Fatal error : clock_gettime() failed : Operation not permitted
ntp              | +624270944-01-21T11:54:16Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS -NTS -SECHASH +IPV6 -DEBUG)
ntp              | +624063116-02-27T18:29:44Z Fatal error : clock_gettime() failed : Operation not permitted
ntp              | +695627639-07-24T16:14:32Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS -NTS -SECHASH +IPV6 -DEBUG)
ntp              | +695419811-08-30T22:50:00Z Fatal error : clock_gettime() failed : Operation not permitted

... and it goes on and on.

Here's my docker-compose.yml setup:

ntp:
    image: cturra/ntp:latest
    container_name: ntp
    restart: always
    ports:
      - 123:123/udp
    cap_add:
      - SYS_TIME
    read_only: true
    tmpfs:
      - /etc/chrony:rw,mode=1750
      - /run/chrony:rw,mode=1750
      - /var/lib/chrony:rw,mode=1750
    environment:
      - NTP_SERVERS=time.cloudflare.com

I tried both with and without the SYS_TIME privilege, no difference.

Any help would be appreciated!

how can i set container so that it does not uses any exteranl internet ntp servers.

how can i set container so that it does not uses any exteranl internet ntp servers(like I dont want to use servers like time.cloudfare.com). What I want is that I will manually set time of my host and then all ntp clients of my host should synchronise with that time.
For example I want my time to 10 days behind utc.

Without docker I was able to do this by setting the server directive for ntp as (127.127.1.0),intead of ntp.ubuntu.com. So the ntp server do not syncs time with ntp.ubuntu.com, it only sends to client what time is available on server itself.

How do I change the time sync interval?

The server accesses IP address 162.159.200.1 (time.cloudflare.com) every 64.5 seconds.
How can I increase the time synchronization interval? So that the time is synchronized (with the remote Cloudflare server) every 10 minutes.

Question: Run NTP Offline

Hey,

it's me again.
I have a question: Is it possible to run the server offline or more like in an (mini) intranet? I have an IPC (industrial pc) which is connected to sensor measurement systems, those systems should be synchronized in time, but neither the IPC nor the measurement systems have access to the internet or intranet they run complete autak/by there self.

Thanks for any answer

Not working on Raspberry Pi

Hello,
I've got cturra deployed on my Raspberry Pi server
My docker -compose file:

 services:
                  ntp:
                    build: .
                    image: cturra/ntp:latest
                    container_name: ntp
                    restart: always
                    ports:
                      - 123:123/udp
                    cap_add:
                      - SYS_TIME
                    read_only: true
                    tmpfs:
                      - /etc/chrony:rw,mode=1750
                      - /run/chrony:rw,mode=1750
                      - /var/lib/chrony:rw,mode=1750
                    environment:
                      - NTP_SERVERS="time1.google.com,time2.google.com,time3.google.com,time4.google.com"
                      - LOG_LEVEL=0

In logs I can see only this:

          2022-11-22T12:17:22Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
            2022-11-22T12:17:22Z Disabled control of system clock

And NTP is not working. I've found in one of the issues that the problem can be with "libseccomp2", I've checked and found that "libseccomp2" is installed on my system.
Any suggestion?

listen udp4 0.0.0.0:123: bind: address already in use. (Docker MacOS only)

Hello,
We are using the docker-ntp projects for month but recently we got this issue:

With the command:

docker run --name=ntp
--restart=always
--detach
--publish=123:123/udp
cturra/ntp

We got the following error message :
docker: Error response from daemon: driver failed programming external connectivity on endpoint ntp (4a4b3c16599cea9cee1802fffc845b7bdb0517e656e05fa1ad2e7ff5e021c63a): Error starting userland proxy: listen udp4 0.0.0.0:123: bind: address already in use.

this happens only on docker Mac version >= v3.2.0 (tested on all the version >= 3.2.0. Up to now, the docker-ntp was working with no problem on Mac and Linux. If I downgrade to 3.1.0 on Mac it works. Of course, i'v checked that I have
I suppose that this problem is related only to the docker engine on Mac and has nothing to do with the docker-ntp project, but before opening an issue in the docker Mac project, is there anything is miss ? I there additional rights or flags to start this container ?

Thank you for your help.
++

Server not stable for long

Hey nice project!
it runs like a charm but i have the problem, that my server is not stable. I tried a lot of different ntp servers to sync with but even over an hour it is not stable.
I started the server yesterday and even today when i checked the server was not stable:
just a few sudo docker exec ntp ntpctl -s status outputs within 5 minutes:

4/4 peers valid, clock unsynced, clock offset is 591.872ms
4/4 peers valid, clock unsynced, clock offset is 582.678ms
4/4 peers valid, clock unsynced, clock offset is 558.124ms
4/4 peers valid, clock unsynced, clock offset is 549.455ms
4/4 peers valid, clock unsynced, clock offset is -18161.083ms
4/4 peers valid, clock unsynced, clock offset is -18019.615ms
4/4 peers valid, clock unsynced, clock offset is -17914.237ms
4/4 peers valid, clock unsynced, clock offset is -16150.951ms
4/4 peers valid, clock unsynced, clock offset is -9582.942ms

sudo docker exec ntp ntpctl -s peers

peer
   wt tl st  next  poll          offset       delay      jitter
94.16.113.67 0.de.pool.ntp.org
    1  9  2   30s 3167s     -1710.079ms 11807.145ms  33665.677ms
78.46.253.198 1.de.pool.ntp.org
    1 10  2   22s   32s       580.689ms 10336.151ms  31168.227ms
162.159.200.1 2.de.pool.ntp.org
    1 10  3  730s 3287s    -16167.813ms    23.444ms     1.365ms
91.202.42.81 3.de.pool.ntp.org
    1  9  2  151s 3288s     -1709.630ms 11807.984ms  33665.965ms

what i have tried as servers so far:

  • default (time.cloudflare.com)
  • google (time1.google.com,time2.google.com,time3.google.com,time4.google.com)
  • unspecific pool.ntp.org (pool.ntp.org)
  • specific pool.ntp.org (0.de.pool.ntp.org,1.de.pool.ntp.org,2.de.pool.ntp.org,3.de.pool.ntp.org)

the unspecific pool.ntp.org worked the best so far - got a stable server after like 2 minutes but not for long.

Im running the docker container on an ubuntu 16.04 server - Docker version 18.09.3, build 774a1f4

hope someone got an idea.

Time accuracy

Hello, can I ask whether the project can obtain time from multiple upstream servers and provide a more accurate time to the service based on it

Migration to chrony broke IPv4 connectivity

My NTP server address is ntp.smirnov.tk
It has IPv4 and IPv6.

Today night container was upgraded and some clients can't get reply from my NTP server.

You can see it here: https://www.ntppool.org/a/smirnov
IPv4 is dead, but IPv6 is ok.

Also this service shows IPv4 dead: https://servertest.online/ntp

But this service shows IPv4 alive: https://keetweej.vanheusden.com/query_ntp.php

UPD: I used docker tag cturra/ntp:strip-quotes and now IPv4 connectivity is OK. So, I think, it's some kind of problem in chrony update.

Docker update

I see a new version on docker hub but no file changes since 2 months on the repo. Could you validate that there is an update and what is in it?

Modifying NTP servers at runtime, without restarting?

Is there an easy way to "poke" your container (once running) with a new set of NTP servers, without having to restart it?

I don't think Docker allows modifying environment variables once a container is running, besides I think your startup.sh script would have to re-run.

Could I modify the /etc/chrony/chrony.conf file instead? Does chrony cache the servers once it runs, or does it always parse the file?

container doesn't start in a unprivileged lxc container

My docker environment is running in an unprivilged lxc container.
When I try to run docker-ntp I receive following error.
ntp | 2020-12-27T09:09:51Z chronyd version 3.5.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS -SECHASH +IPV6 -DEBUG)
ntp | 2020-12-27T09:09:51Z Fatal error : adjtimex(0x8001) failed : Operation not permitted

cturra/ntp:latest "/bin/sh /opt/startu…" 13 seconds ago Restarting (1) 4 seconds ago

Do you have a hint?

Not running on ARM architecture (Odroid C2)

Hi,
I have the following docker-compose file:
version: '3.4'
services:
ntp:
#build: .
image: cturra/ntp:latest
container_name: ntp
restart: always
ports:
- 123:123/udp
cap_add:
- SYS_NICE
- SYS_RESOURCE
- SYS_TIME
environment:
- NTP_SERVERS=time.cloudflare.com

I tried to run it on my ArchLinux Odroid C2 Server but I always get the error:
ntp | standard_init_linux.go:211: exec user process caused "exec format error"

Then I copied the same docker-compose file to my Macbook Pro and ran it there with Docker-Compose up and everything just worked out of the box.

I prefer using Docker-Compose instead of Dockerfile.
Is there any chance I can run my personal ntp server on the Odroid?
When I googled the error message I came across a post where someone has written that it is a architecture problem.

Am I only stupid and don't get it to run, or is my assumption true?
I'm new to Docker, so pardon me if I made a stupid mistake or if I don't get something right. But I think I 'understood' how docker should be running.

Kind regards,
Daniel Oberlechner

missing multi arch builds in docker hub

Host: Raspberry Pi 4
OS: Ubuntu Server 20.04.1 LTS (aarch64)

This morning I tried to update my cturra/ntp container from image ID 7d5219fcd338 to 6deea110137f. The previous image launched a container just fine and was happily providing NTP services to my network.

The new image won't launch a container. It throws the error message "standard_init_linux.go:219: exec user process caused: exec format error"

Googling that message suggests that this error is likely caused by trying to run an image intended for a different architecture. But I'm not doing anything different than I did with the previous image.

The page at https://hub.docker.com/r/cturra/ntp indicates that "linux/arm64" is among the supported architectures for this image.

I'm still finding my feet with Docker, so I'm open to the possibility that I'm doing something daft without realising, but I can't work out what. The previous image worked; the current image doesn't. And I'm stumped.

Any suggestions, or clue-by-fours?

sntp: Clock select failed

Bringing up the docker with the following docker compose service:

  local-ntp:
    image: cturra/ntp:latest
    container_name: local-ntp
    restart: always
    privileged: true
    ports:
      - 123:123/udp
    environment:
      - NTP_SERVERS=time.google.com
      - LOG_LEVEL=0
      - TZ=Etc/GMT-4

When I try to query the NTP from my host (mac) with sntp -d 192.168.176.2 I get

sntp: Exchange failed: Timeout
sntp_exchange {
        result: 6 (Timeout)
        header: 00 (li:0 vn:0 mode:0)
       stratum: 00 (0)
          poll: 00 (1)
     precision: 00 (1.000000e+00)
         delay: 0000.0000 (0.000000000)
    dispersion: 0000.0000 (0.000000000)
           ref: 00000000 ("    ")
         t_ref: 00000000.00000000 (0.000000000)
            t1: E8D89171.D7E4CD74 (3906507121.843334999)
            t2: 00000000.00000000 (0.000000000)
            t3: 00000000.00000000 (0.000000000)
            t4: 00000000.00000000 (0.000000000)
        offset: FFFFFFFF8B93B747.140D994600000000 (-1953253560.921667576)
         delay: FFFFFFFF17276E8E.281B328C00000000 (-3906507121.843335152)
          mean: 0000000000000000.0000000000000000 (0.000000000)
         error: 0000000000000000.0000000000000000 (0.000000000)
          addr: 192.168.176.2
}
sntp: Clock select failed

ntp in docker swarm

I am trying to spin up this ntp server in a docker swarm. The container is never able to spin up even though it works locally.
image

New image features?

I see a new image version was deployed to docker hub. Any information what has changed?

[Feature request] possiblity to sync system clock and not have default ntp server.

Hi!
Just wanted to know if it would be possible to add an environment variable to be able to sync the system clock from the docker container?
I know it was taken off to have it as not a privilege container. But it would be great to have the option if we want.
My reason, i run chrony as both my client and server on my server, so i kinda don't want to have 2 chrony process if possible ^^'

Secondly i wanted to know if by setting a volume (read-only) to the chrony.conf, with my own conf file, if it would be overwritten with the default ntp server?
Correct me if i'm wrong but it shouldn't be able to modify it, if it is mounted as read-only right?

Provide option to serve system clock time

For systems without internet connectivity, it would be nice to have an option to use the system clock as a time source. I've managed (trough command injection :P) to set chrony to use the system clock with NTP_SERVERS set to --env=NTP_SERVERS="$(printf "%s\n%s\n%s" 127.127.1.0 "local stratum 10" "# ")" which resutls in the following /etc/chrony/chrony.conf file:

# https://github.com/cturra/docker-ntp

# chrony.conf file generated by startup script
# located at /opt/startup.sh

# time servers provided by NTP_SERVER environment variables.
server 127.127.1.1
local stratum 10
#  iburst

driftfile /var/lib/chrony/chrony.drift
makestep 0.1 3
rtcsync

allow all

from my testing, it looks like local stratum 10 is required for this to work, no idea why.

Support for Ordoid C2 AARCH8 - firstly it worked but now it doesn't

Have you changed something in partikular or why won't the docker compose image not start anymore?

version: '3.4'

services:
ntp:
image: cturra/ntp-multiarch:latest
container_name: ntp
ports:
- 123:123/udp
cap_add:
- SYS_NICE
- SYS_RESOURCE
- SYS_TIME
environment:
- NTP_SERVERS=time.cloudflare.com,it.pool.ntp.org,time.google.com
restart: always
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.