Windows users:
The solution is very simple. Simply open a powershell prompt and enter:
docker run --privileged --rm alpine date -s "$(Get-Date ([datetime]::UtcNow) -UFormat "+%Y-%m-%d %H:%M:%S")"
To check that it works, run the command:
docker run --rm -it alpine date
My solution is inspired by something I found in docker forum thread. Anyways, it was the only solution that worked for me on docker desktop, except for restarting my machine (which also works). Here's a link to the original thread: https://forums.docker.com/t/syncing-clock-with-host/10432/23
The difference between the thread answer and mine is that mine converts the time to UTC time, which is necessary for e.g. AWS. Otherwise, the original answer from the forum looks like this:
docker run --privileged --rm alpine date -s "$(date -u "+%Y-%m-%d %H:%M:%S")"
docker
commands on, you may see time skew, and things like mounting volumes won't work as you might expect. This also happens when you set up a remote docker machine, e.g. on DigitalOcean. – Rafferty