dotnet/dotnet-docker

Alpine Docker images no longer have tzdata package in 3.0

mthalman opened this issue · 6 comments

Alpine Docker images no longer have tzdata package in 3.0

Beginning with the 3.0 release, the tzdata package has been removed from all Alpine Docker images.

Details

This package was removed because it wasn't required for the main set of scenarios and to have consistency between the runtime-deps images across all Linux distros. This package is still installed in the 2.x images for Alpine so this will be something to be aware of when migrating from 2.x to 3.0.

You may be impacted by this if you use any of the Alpine images for 3.0 and your code has a dependency on the tzdata package, such as using the System.TimeZoneInfo API. In that case, you'll need to update your Dockerfile to explicitly install the package:

RUN apk add --no-cache tzdata

We deployed our first .net core microservice to our UAT environment 3 days ago. It took me few hours to find out that tzdata was missing from the docker package! @mj1856 you should probably document this. Anyone using TZConvert within an Alpine docker will have to include this package.

@seroche - Added here. Thanks.

Hello Sorry for commenting on closed post.
But actually i am facing the same issue here. I am using ubuntu based dot net core image 3.0 .
My aim is very simple, i just need to find out current CST time.
I have installed the tzdata package but still getting ResponseMessage: "System.TimeZoneNotFoundException: Exception of
type 'System.TimeZoneNotFoundException' was thrown.↵ at TimeZoneConverter.TZConvert.GetTimeZoneInfo(String windowsOrIanaTimeZoneId)↵

Here is my docker file :
`FROM mcr.microsoft.com/dotnet/core/sdk:3.0-bionic AS build-env

WORKDIR /app
ADD UbuntuScript.sh /UbuntuScript.sh
RUN /UbuntuScript.sh

Copy everything else and build

COPY . ./
RUN dotnet publish xyz -c Release -o out

Build runtime image

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic
WORKDIR /app

#COPY --from=build-env /app/out .
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "xyz.dll"]`

Ubuntu Script file :

set noninteractive installation

export DEBIAN_FRONTEND=noninteractive
#install tzdata package
apt-get update
apt-get install tzdata -y

set your timezone

ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata

dot net core code where i am using
TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneConverter.TZConvert.GetTimeZoneInfo("Central Standard Time"));
@mj1856 @mthalman please help, i m sure i am missing some small thing.

@tushi0407 - Have you verified tzdata is installed in the image where your app is contained? From what you pasted, it looks like you're installing the package into your SDK image rather than your runtime image.

Thanks for your reply @mthalman , Actually I am very new to docker. So could you please help me how I can check that? What needs to be change on docker file?

Thanks @mthalman ..it is resolved now.I was doing the same mistake . I have changed the place where i was installing tzdata.Now i am installing it under run time image.I have placed ADD UbuntuScript.sh /UbuntuScript.sh RUN /UbuntuScript.sh just after FROM ../dotnet/core/aspnet:3.1-bionic WORKDIR /app. It is working now.