dockur / windows

Windows inside a Docker container.
MIT License
15.46k stars 1.26k forks source link

QEMU time #465

Open baiomys opened 1 month ago

baiomys commented 1 month ago

Is your question not already answered in the FAQ?

Is this a general question and not a technical issue?

Question

Windows time is out of sync without ARGUMENTS: "-rtc base=localtime" Should be handy to create dedicated ENVIRONMENT option for this if not created already.

kroese commented 1 month ago

I will add this option by default in the next version so that you dont need to manually specify it.

kroese commented 1 month ago

This is now fixed in v3.05.

the4anoni commented 2 weeks ago

I have same issue, time difference between my debian 12 host and windows container is 2 hours.

dockurr/windows latest d380ee3be346 7 hours ago 371MB The image I am currently using, it happened on previous versions too.

@kroese

kroese commented 2 weeks ago

I added this parameter "-rtc base=localtime" @baiomys suggested. So I dont know what more can I do.

Are you sure you set the correct timezone setting? Because that can also cause a difference.

the4anoni commented 2 weeks ago

I added this parameter "-rtc base=localtime" @baiomys suggested. So I dont know what more can I do.

Are you sure you set the correct timezone setting? Because that can also cause a difference.

I did set correct timezone. After I do NTP sync in Windows time is ok, but is goes back after Windows reboot.

kroese commented 2 weeks ago

@baiomys Do you have any idea?

the4anoni commented 2 weeks ago

@baiomys Do you have any idea?

Maybe that fix just needs to be reverted or changed to something else?

https://docs.getutm.app/settings-qemu/qemu/

Use local time for base clock

This specifies the -rtc base=localtime option in QEMU. This synchronizes the guest clock to the local clock without any offsets. On some Linux guests, the RTC base is expected to be UTC and so this option should be disabled.

baiomys commented 2 weeks ago

"-rtc base=utc" in ARGUMENTS should help 95% guests run local time, so turning this option ON by default was reasonable

taylormia commented 1 week ago

My host is running Linux Mint 21.3 and I have added the ARGUMENTS: "-rtc base=localtime" statement to my existing compose file and restarted the container. But the Windows 11 time still shows a +5 hour difference from my local time which is Central Daylight Time. I did a test spinning up a new container with the above arguments line and after a new download and setup, the time on the Win11 container showed the correct local time after changing the time zone in the Windows time/date settings. I then shut down the container and started it up again keeping the ARGUMENTS statement intact. After startup, the time was not correct showing the same +5 hour time difference.

Is there any way to make the ARGUMENTS statement to take effect and persist on an existing container or after restart of the container.

Thanks

baiomys commented 1 week ago

"-rtc base=localtime" is set by default since version v3.05, did you try "-rtc base=utc"?
Anyway, after changing this option you need to manually RESYNC TIME in windows at least once to make it persistent.

taylormia commented 1 week ago

I have resynced the time in the Win11 container and restarted it with no change using "rtc base=localtime" I have also tried "rtc base=utc" and resynced the Win11 time and restarted with no change.

taylormia commented 1 week ago

Still does not work - but I have implemented a workaround by invoking a batch file at windows startup to sync time with NTP to get my correct local time.

the4anoni commented 4 days ago

Still does not work - but I have implemented a workaround by invoking a batch file at windows startup to sync time with NTP to get my correct local time.

can you share that script here?

taylormia commented 4 days ago

@the4anoni Sure. Here's the content of the batch file:

@echo off
SC start "W32Time" & W32tm /ReSync

The batch file is placed in this directory: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup