我正在尝试设置基于 windows nano server 2019 Build 1809 的 WindowsContainer 的时区。
为 linux 容器执行此操作的最简单方法之一是设置 TimeZone 环境变量,如下所示:
docker run -e TZ=Asia/Kolkata ubuntu date
对于 Windows 容器,我们是否有类似的东西。基于一般的 Windows 方法,我尝试使用 PowerShell 之类的(如下所示)在入口点脚本中设置它,但它也给了我一个错误。
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
关于如何为基于 Windows Nanoserver 2019 Build 1809 的 Windows 容器完成此操作有任何想法吗?
最佳答案
已编辑:如 Pierre-Luc Champigny指出,据微软称,现在 ltsc 版本和即将推出的版本都支持此功能:https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/virtual-time-zone
无法在 Windows Server Core 容器上正确设置全局化设置,例如时区、语言或 Windows 位置。
tzutil
抛出权限不足错误 似乎您必须确保容器主机上的时区正确。
这没有多大意义,AFAIK,关于容器的全部内容是将其作为镜像发送一次并在任何地方运行,使用 环境隔离和完整性 .. 对?!
不管怎样,你可以看到更多的细节 issue on github .
另外,我打开了这个 suggestion on Windows Server uservoice ,改变这种行为。
另外,我打开了这个 feature suggestion for improving Azure AKS host configuration对于时区。
关于docker - 为 Windows 容器设置时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55514732/