Skip to content

Alpine docker image does not obey local timezone anymore #59636

@nalla

Description

@nalla

Description

The release 6.0.0-rc.1 does not obey the local timezone information. This is a regression, see the following steps to reproduce

Steps to reproduce

private static void Main(string[] args)
{
	Console.WriteLine(TimeZoneInfo.Local.DisplayName);
}

Working

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
    WORKDIR /build
    COPY src/Foo.sln .
    COPY src/Foo/*.csproj ./Foo/
    RUN dotnet restore ./Foo.sln
    COPY src/Foo/ ./Foo/
FROM build as publish
    WORKDIR /build/Foo
    RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS runtime
    RUN apk update --no-cache && apk upgrade --no-cache
    RUN apk add --no-cache tzdata
    ENV TZ=Europe/Berlin
    ENV LANG=de_DE.UTF-8
    ENV LANGUAGE=${LANG}
    ENV LC_ALL=${LANG}
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    WORKDIR /app
    COPY --from=publish /build/Foo/out ./
    ENTRYPOINT [ "dotnet", "Foo.dll" ]

This will produce the following output

(UTC+01:00) CET

Bug

When you now take the same code, change target framework from net5.0 to net6.0 and use the same Dockerfile as a base and use mcr.microsoft.com/dotnet/sdk:6.0 and mcr.microsoft.com/dotnet/aspnet:6.0-alpine, you will get the following output

(UTC+00:00) Coordinated Universal Time

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions