Dotnet-docker: 3.0 ubuntu images are missing tzdata

Created on 9 Aug 2019  路  8Comments  路  Source: dotnet/dotnet-docker

Steps to reproduce the issue

Deploy a dotnet core application that calls:

TimeZoneInfo.FindSystemTimeZoneById("America/New_York");

Expected behavior

Get the timezoneInfo

Actual behavior

throws an exception:

System.TimeZoneNotFoundException: The time zone ID 'America/New_York' was not found on the local computer.
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path '/usr/share/zoneinfo/America/New_York'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Internal.IO.File.ReadAllBytes(String path)
   at System.TimeZoneInfo.TryGetTimeZoneFromLocalMachine(String id, TimeZoneInfo& value, Exception& e)
   --- End of inner exception stack trace ---
   at System.TimeZoneInfo.FindSystemTimeZoneById(String id)

I did try with tags:
mcr.microsoft.com/dotnet/core/aspnet:3.0-disco and
mcr.microsoft.com/dotnet/core/aspnet:3.0-bionic

As the error states the "timezone info is missing" (Could not find a part of the path '/usr/share/zoneinfo)

The fix is easy enough, install tzdata:

RUN apt-get install tzdata -y

...but it probably should be included in the core container image anyway

area-dockerfiles enhancement

Most helpful comment

It would be nice if this was mentioned in the migration guide, for migration from dotnet core 2 to dotnet core 3. Something like if you're using alpine images and using anything of dates be sure to add the tzdata package in your docker file.

Even if you aren't using timezones explicitly without this package the following code responds differently.

if (DateTime.TryParse(someDateString, null, DateTimeStyles.AssumeLocal, out DateTime dt))
{
....
}

All 8 comments

Would a PR for adding tzdata to https://github.com/dotnet/dotnet-docker/tree/master/3.0/runtime-deps for the Ubuntu images be accepted? It looks like it's included in the alpine builds, but not bionic, buster-slim, and disco

Assigning to Matt for some investigation.

I've confirmed that adding the package resolves the issue of the call to TimeZoneInfo.FindSystemTimeZoneById failing.

The tzdata package ends up adding 2.1 MB to the image. Seems reasonable to add it for consistency with Alpine.

@richlander, @dagood, @leecow, @mthalman, @dleeapho, @janvorli - We have been including tzdata in our Alpine based runtime-deps images since the beginning. tzdata is not however included in the Debian and Ubuntu based runtime-deps images. The Debian and Ubuntu images mirror the packages included in the deb packages created in core-setup. This issue is asking why it is not included in the Debian and Ubuntu based images. tzdata feels like an optional component as it is not required for all scenarios. An argument could be made that the Debian and Ubuntu images should include tzdata and that it should be removed from the alpine based images since they are intended to be the smallest light weight images provided.

Questions:

  1. Should the Debian and Ubuntu runtime-deps images include tzdata?
  2. Should the Alpine runtime-deps images continue to include tzdata? The image with it is 12.3 MB on disk versus 12.3MB without it.
  3. If tzdata is added to the Debian and Ubuntu runtime-deps images, should the core-setup produced deb packages also be updated to include it?
  1. If tzdata is added to the Debian and Ubuntu runtime-deps images, should the core-setup produced deb packages also be updated to include it? The image with it is 12.3 MB on disk versus 12.3MB without it.

We use the same runtime-deps Debian package for all distros, so IMO we shouldn't because it would reduce compatibility. I think it would be good to add it as a "suggests" or "recommends" dependency, though.

Agreed on not adding it to Debian and Ubuntu. runtime-deps is meant to enable baseline functionality (hello world for all default templates) as generically as possible.

In order to maintain consistency among the runtime-deps images, we've decided that none of the runtime-deps images should have the tzdata package installed. It does currently exist in the Alpine-based runtime-deps images but our intention is to remove it (https://github.com/dotnet/dotnet-docker/issues/1311). Consumers of these images that need to call into the TimeZoneInfo API will need to explicitly install the tzdata package in their own Dockerfile.

It would be nice if this was mentioned in the migration guide, for migration from dotnet core 2 to dotnet core 3. Something like if you're using alpine images and using anything of dates be sure to add the tzdata package in your docker file.

Even if you aren't using timezones explicitly without this package the following code responds differently.

if (DateTime.TryParse(someDateString, null, DateTimeStyles.AssumeLocal, out DateTime dt))
{
....
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesstow picture jamesstow  路  6Comments

deployable picture deployable  路  8Comments

agr picture agr  路  3Comments

galvesribeiro picture galvesribeiro  路  7Comments

cypressious picture cypressious  路  5Comments