dotnet / dotnet/announcements

.NET Core Alpine Docker Image Ready for Testing

Open
#49 0 comments 0 reactions 1 assignee Claimed by @richlander View on GitHub
.NET Core 2.1 Docker
Dominant language
No language data
Stars
1.4k
Forks
53
PR merge metrics
No merged PRs in 30d

Description

# .NET Core Docker Alpine Image Ready for Testing

Update: Alpine is now supported with [.NET Core 2.1](https://blogs.msdn.microsoft.com/dotnet/2018/05/30/announcing-net-core-2-1/).

An [Alpine](https://hub.docker.com/_/alpine/)-based Docker image is now available for .NET Core. Alpine is much smaller than Debian, which we have used for the .NET Core base image to date. There have been many requests for an Alpine image. We are pleased to make it available. Please check out [.NET Core Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/README.md) to see examples of using this image.

We have added two new images:

- `2.1-runtime-alpine`
- `2.1-runtime-deps-alpine`

Alpine support is part of the .NET Core 2.1 release. .NET Core 2.1 images are currently provided at the [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet) repo, including the new Alpine images.

## Discussion

Please share your thoughts on this change and see what others are saying at:

* [dotnet/dotnet-docker-nightly #500](https://github.com/dotnet/dotnet-docker-nightly/issues/500)

## Details

* [dotnet/dotnet-docker-nightly #480](https://github.com/dotnet/dotnet-docker-nightly/pull/480)
* [dotnet/announcements #20](https://github.com/dotnet/announcements/issues/20)

The primary goal of Alpine is very small deployments. We have been considering various design decisions to make .NET Core Alpine base images as small as possible to align with that. In this first iteration, we enabled [.NET Core 2.0 Globalization Invariant Mode](https://github.com/dotnet/announcements/issues/20) in order to reduce the default size of the image. This change reduced the image by ~30MB. You can see the reduction in size for .NET Core images relative to Debian in the following table.

|2.1 Image|Debian|Alpine|
|----- |------|------|
|`-deps` |153MB (68MB compressed) |13.8 MB (6MB compressed)|
|`-runtime`|222MB (96MB compressed) |82.5 (34MB compressed)|

Note: The compressed size is what you will see in a [registry](https://hub.docker.com/r/microsoft/dotnet/tags/) and is the wire-size cost.

We are also considering saving more space by native-compiling fewer assemblies. .NET Core runtime assemblies are native-compiled with the [crossgen tool](https://github.com/dotnet/coreclr/blob/master/Documentation/building/crossgen.md) in the [Ready2Run format](https://github.com/dotnet/coreclr/blob/master/Documentation/botr/readytorun-overview.md). Native-compiled code delivers superior startup performance but at the cost of 2-3x larger files. We have the opportunity to compile less, skipping compiling assemblies in part or in whole. We believe that we can save at least another 10MB through compiling less without a material drop in performance. For scenarios that value size over startup or where wire cost is significant, it may be valuable to aggressively reduce the number/% of compilation.

Alpine images are only available for .NET Core 2.1. At the current time, only Runtime images are available. We intend to offer SDK images at a later date.

Use cases that cannot tolerate Globalization invariant mode can reset the `DOTNET_SYSTEM_GLOBALIZATION_INVARIANT` environment variable and install the ICU package. Please check out [.NET Core Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/README.md) to see examples of using this image with and without Globalization Invariant Mode enabled.

## Call to Action

Please test your workloads with the new Alpine image. In particular, we want to know if enabling .NET Core Globalization Invariant Mode is acceptable/appreciated.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.