0

The current time & the time on my windows PC is 12:24 on 4/6/21, but running

docker exec -it {container} date

Gives me the time Fri May 21 06:43:19 UTC 2021, which is a little over 2 weeks behind. From what I've read, docker should be taking the date from my machine, so I can't figure out why they're so out of sync.

Stopping & upping my docker-compose doesnt reset the time - the gap remains the same. What do I need to do to get them synced? Is there something missing from my docker-compose file?

be2213444
  • 607
  • 1
  • 4
  • 10

1 Answers1

0

Docker takes date/time based on its own time/zone settings, as explained at https://www.ivankrizsan.se/2015/10/31/time-in-docker-containers/ .

Try to synchronize it by adding to your image the NTPd service as demostrated in above article.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • The time zone is based on `/etc/localtime` inside the container, but the actual clock itself is shared with the host (and maintained by the host's kernel) (on native Linux). It'd be very unusual to run ntpd inside a container; both because it would change the host-global time, and because a container usually only runs one process. – David Maze Jun 04 '21 at 13:04
  • @DavidMaze In that case, what would you suggest? It's not just a timezone problem anyway - the date is way off too – be2213444 Jun 04 '21 at 13:21