I am trying to set the timezone of a WindowsContainer which is based on the windows nano server 2019 Build 1809.
One of the simplest way of doing it for linux containers is to set the TimeZone environment variable as shown below:
docker run -e TZ=Asia/Kolkata ubuntu date
Do we have anything similar for Windows Containers. Based on general windows approach i am trying to set it in the entrypoint script using PowerShell like (as shown below) but it is also giving me an error.
Set-TimeZone -Name "India Standard Time"
Set-TimeZone : Access is denied
At line:1 char:1
+ Set-TimeZone -Name "India Standard Time"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : FromStdErr: (:) [Set-TimeZone], Win32Exception
+ FullyQualifiedErrorId : SetTimeZoneFailed,Microsoft.PowerShell.Commands.SetTimeZoneCommand
Any idea on how this can be done for Windows Containers based on Windows Nanoserver 2019 Build 1809?
Tzutil.exe and PowerShell's Set-TimeZone as well as all apps changing the timezone through the system APIs will be able to set the timezone from within containers in --isolation=process
mode starting from Windows Server 2022. Whatever works on the host will work inside containers, including DST even if the container's timezone has a different DST policy than the host, for example some regions enter/exit DST at a different date, or not at all.
Initially, new and existing containers will inherit the host's timezone (the timezone bias and all other timezone settings, such as the DST policy) as previously, but once set from within a particular container instance, the container in question will stick to it for the rest of its lifetime, ever across reboots, until changed again.
Changing the timezone within a particular container instance has no side effect on other containers, and of course no side effect on the host and vice-versa.