Modifying NTP servers at runtime, without restarting?
jflambert opened this issue · 3 comments
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?
the ntp server list in the chrony.conf
file is populated on startup from the NTP_SERVERS
environment variable. this needs to be done before the chronyd process is started.
if you update the configuration file after the container is running, you'd still need to restart the chronyd process. since this container is bound to the startup script process, if the running chronyd pid exists, it will kill pid 1 (the startup script) and the container will shutdown.
if you're concerned about downtime while you update your ntp server list, ntp clients are resilient to not being able to reach an ntp server. i'd expect you should be able to stop and relaunch a new ntp server container and get it's clock in sync within a minute with a simple one-liner like:
docker rm -f ntp && docker run --name=ntp --detach=true --restart=always --publish=123:123/udp --env=NTP_SERVERS="time1.google.com,time2.google.com" --cap-add=SYS_TIME cturra/ntp
*assuming your container name is: ntp
hope this helps point you in the right direction.
quick follow up, i am going to close this issue because this container is designed around single process in a container best practices. i have a strong preference not to put a supervisor process around chronyd to support in-container process restarting where possible.
Thanks for the feedback.