Setting Docker Container time to correct time independent of incorrect host time

Ok, so in our SaaS we use GPU instances from community clouds like vast.ai or runpod, where we provide the docker image we want to run and the host is controlled by the provider.

We have noticed that sometimes the system clock time of host machines is off by a few seconds, which creates weird bugs in monitoring and the metrics of orchestrating a number of GPU instances .
Imagine having a bunch of worker machines and they don’t agree which time it is.

So, I was hoping I could run a tool like chrony inside the docker container, unfortunately that doesn’t seem to work since docker seems to share the system clock time.

Any ideas for this problem?

A container is basically a process on the host, so it will use the time of the host. You can only change the timezone, but not the time.

You can check if faketime helps in your usecase: Ubuntu Manpage: faketime - manipulate the system time for a given command

But it will not synchronize the time from an NTP server