时区查找在基础 docker aspnet 图像中有效,但在 aspnet:6.0-alpine3.15 中无效
Timezone lookup works in base docker aspnet image but not aspnet:6.0-alpine3.15
我有一些代码可以像这样按 ID 查找时区
string tz = "Pacific Standard Time";
var timezone = TimeZoneInfo.FindSystemTimeZoneById(tz);
在我的 Dockerfile 中,如果我将图像声明为
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS release
代码有效,但是如果我尝试切换到 Alpine(即使我添加了 tzdata)它会失败并出现异常
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.15 AS release
RUN apk add --no-cache tzdata
异常:
System.TimeZoneNotFoundException: The time zone ID 'Pacific Standard Time' was not found on the local computer.
---> System.IO.FileNotFoundException: Could not find file '/usr/share/zoneinfo/Pacific Standard Time'.
我 认为 我缺少包裹或其他东西,但我不确定。我需要向 Alpine 添加什么才能正确选择 Windows 样式时区?
ICU 库包含从 Windows 时区到 IANA 时区的映射。另外,确保不变全球化关闭:
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
RUN apk add --no-cache icu-libs tzdata
我有一些代码可以像这样按 ID 查找时区
string tz = "Pacific Standard Time";
var timezone = TimeZoneInfo.FindSystemTimeZoneById(tz);
在我的 Dockerfile 中,如果我将图像声明为
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS release
代码有效,但是如果我尝试切换到 Alpine(即使我添加了 tzdata)它会失败并出现异常
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.15 AS release
RUN apk add --no-cache tzdata
异常:
System.TimeZoneNotFoundException: The time zone ID 'Pacific Standard Time' was not found on the local computer.
---> System.IO.FileNotFoundException: Could not find file '/usr/share/zoneinfo/Pacific Standard Time'.
我 认为 我缺少包裹或其他东西,但我不确定。我需要向 Alpine 添加什么才能正确选择 Windows 样式时区?
ICU 库包含从 Windows 时区到 IANA 时区的映射。另外,确保不变全球化关闭:
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
RUN apk add --no-cache icu-libs tzdata