Problem
The system time in WSL is out of sync with your Windows system time. Docker containers launched from WSL suffer from the same incorrect time, which they inherit from WSL. I've observed this in WSL2 Ubuntu in Windows 10.
Solution
We can use ntpdate
to update the date & time according to some source we trust. Generally running an ntpd
daemon is preferred over using ntpdate
, but it's quick and does the job and I'm not worried about issues with running services getting confused about living in a different time all of a sudden.
ntpdate -v
If this command gives Command 'ntpdate' not found
, run sudo apt install ntpdate
.
Then:
sudo ntpdate time.windows.com
Note: Other NTP servers can be found on the NTP Pool Project website.
Use date
to verify the date & time are now correct.