How to make sure docker’s time syncs with that of the host?

The source for this answer is the comment to the answer at: Will docker container auto sync time with the host machine?

After looking at the answer, I realized that there is no way a clock drift will occur on the docker container. Docker uses the same clock as the host and the docker cannot change it. It means that doing an ntpdate inside the docker does not work.

The correct thing to do is to update the host time using ntpdate

As far as syncing timezones is concerned, -v /etc/localtime:/etc/localtime:ro works.

Leave a Comment