Timezone lookup works in base docker aspnet image but not aspnet:6.0-alpine3.15

Viewed 231

I have some code that looks up timezones by ID like so

string tz = "Pacific Standard Time";
var timezone = TimeZoneInfo.FindSystemTimeZoneById(tz);

In my Dockerfile if I declare the image as

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS release

the code works, however if I try to switch to Alpine (even if I add the tzdata) it fails with an exception

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.15 AS release
RUN apk add --no-cache tzdata

Exception:

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'.

I think I'm missing a package or something but I'm not sure. What do I need to add to Alpine so it'll pick up Windows style timezones properly?

1 Answers
Related