You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps中Windows容器Dockerfile时区设置失败求助

Windows容器(.NET Framework 4.8)时区设置解决方案

针对你遇到的时区设置错误,以下是两种可行的解决方法:

方法1:修复PowerShell命令的引号问题

你的错误源于Dockerfile中PowerShell命令的引号解析问题——外层双引号被shell处理后,带空格的时区名称被拆分为多个参数,导致PowerShell识别到多余的位置参数。调整命令的引号写法即可解决:

RUN powershell -Command "Set-TimeZone -Name 'W. Europe Standard Time'"

或者使用转义双引号的写法:

RUN powershell -Command Set-TimeZone -Name \"W. Europe Standard Time\"

方法2:使用tzutil工具(更简洁稳定)

Windows容器自带tzutil工具,无需依赖PowerShell的复杂引号处理,直接执行以下命令即可完成时区设置:

RUN tzutil /s "W. Europe Standard Time"

验证时区设置

镜像构建完成后,你可以进入容器执行以下命令确认时区是否生效:

  • 用tzutil查看:tzutil /g
  • 用PowerShell查看:powershell -Command Get-TimeZone

内容的提问来源于stack exchange,提问作者Henkie85

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 13:51:01