Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 ubuntu images are missing tzdata #1264

Closed
crochik opened this issue Aug 9, 2019 · 8 comments
Closed

3.0 ubuntu images are missing tzdata #1264

crochik opened this issue Aug 9, 2019 · 8 comments

Comments

@crochik
Copy link

crochik commented Aug 9, 2019

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

@rgmills
Copy link

rgmills commented Aug 13, 2019

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

@MichaelSimons
Copy link
Member

Assigning to Matt for some investigation.

@mthalman
Copy link
Member

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.

@MichaelSimons
Copy link
Member

MichaelSimons commented Aug 23, 2019

@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?

@dagood
Copy link
Member

dagood commented Aug 23, 2019

  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.

@leecow
Copy link
Member

leecow commented Aug 26, 2019

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.

@mthalman
Copy link
Member

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 (#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.

@svrooij
Copy link

svrooij commented Oct 2, 2019

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))
{
....
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants