Install the .NET SDK or the .NET Runtime on Alpine

Important

.NET 8 was released on November 14, 2023. It may take time for the packages to appear in the package manager feeds.

.NET is supported on Alpine and this article describes how to install .NET on Alpine. When an Alpine version falls out of support, .NET is no longer supported with that version.

If you're using Docker, consider using official .NET Docker images instead of installing .NET yourself.

Install the SDK (which includes the runtime) if you want to develop .NET apps. Or, if you only need to run apps, install the Runtime. If you're installing the Runtime, we suggest you install the ASP.NET Core Runtime as it includes both .NET and ASP.NET Core runtimes.

Use the dotnet --list-sdks and dotnet --list-runtimes commands to see which versions are installed. For more information, see How to check that .NET is already installed.

The Alpine package manager supports installing some versions of .NET. If the .NET package is unavailable, you'll need to install .NET in one of the following alternative ways:

Install .NET 8

.NET 8 isn't yet available in the default branch of the Alpine package repository. Use the edge branch to install .NET 8. Alternatively, use one of the following ways to install .NET 8:

Install .NET 7

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following command:

sudo apk add dotnet7-sdk

Install the runtime

The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn't provide the runtime. The following command installs the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following command:

sudo apk add aspnetcore7-runtime

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime, which doesn't include ASP.NET Core support: replace aspnetcore7-runtime in the previous command with dotnet7-runtime:

sudo apk add dotnet7-runtime

Install .NET 6

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following command:

sudo apk add dotnet6-sdk

Install the runtime

The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn't provide the runtime. The following command installs the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following command:

sudo apk add aspnetcore6-runtime

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime, which doesn't include ASP.NET Core support. To install it, replace aspnetcore6-runtime in the previous command with dotnet6-runtime:

sudo apk add dotnet6-runtime

Supported distributions

The following table is a list of currently supported .NET releases and the versions of Alpine they're supported on. These versions remain supported until either the version of .NET reaches end-of-support or the version of Alpine reaches end-of-life.

Alpine Supported Version Available in Package Manager
3.19 .NET 8.0, .NET 7.0, .NET 6.0 .NET 7.0, .NET 6.0
3.18 .NET 8.0, .NET 7.0, .NET 6.0 .NET 7.0, .NET 6.0
3.17 .NET 8.0, .NET 7.0, .NET 6.0 .NET 7.0, .NET 6.0
3.16 .NET 7.0, .NET 6.0 .NET 6.0
3.15 .NET 7.0, .NET 6.0 None

The following versions of .NET are ❌ no longer supported:

  • .NET 5
  • .NET Core 3.1
  • .NET Core 3.0
  • .NET Core 2.2
  • .NET Core 2.1
  • .NET Core 2.0

Supported architectures

The following table is a list of currently supported .NET releases and the architecture of Alpine they're supported on. These versions remain supported until either the version of .NET reaches end-of-support or the architecture of Alpine is supported#. Note that only x86_64, armv7, aarch64 is officially supported by Microsoft. Other architectures are supported by the distribution maintainers, and can be installed using the apk package manager.

Architecture .NET 6 .NET 7 .NET 8
x86_64 3.16, 3.17, 3.18 3.17, 3.18 3.17, 3.18
x86 None None None
aarch64 3.16, 3.17, 3.18 3.17, 3.18 3.17, 3.18
armv7 3.16, 3.17, 3.18 3.17, 3.18 3.17, 3.18
armhf None None None
s390x 3.17 3.17 3.17
ppc64le None None None
riscv64 None None None

Install preview versions

Preview and release candidate versions of .NET aren't available in package repositories. You can install previews and release candidates of .NET in one of the following ways:

Remove preview versions

When using a package manager to manage your installation of .NET, you may run into a conflict if you've previously installed a preview release. The package manager may interpret the non-preview release as an earlier version of .NET. To install the non-preview release, first uninstall the preview versions. For more information about uninstalling .NET, see How to remove the .NET Runtime and SDK.

Dependencies

When you install with a package manager, these libraries are installed for you. But, if you manually install .NET or you publish a self-contained app, you'll need to make sure these libraries are installed:

3.18+

  • ca-certificates-bundle
  • libgcc
  • libssl3
  • libstdc++
  • zlib
  • libgdiplus (if the .NET app requires the System.Drawing.Common assembly)

3.15 - 3.17

  • icu-libs
  • krb5-libs
  • libgcc
  • libintl
  • libssl3
  • libstdc++
  • zlib
  • libgdiplus (if the .NET app requires the System.Drawing.Common assembly)

Use the apk add command to install the dependencies.

If the .NET app uses the System.Drawing.Common assembly, libgdiplus will also need to be installed. Because System.Drawing.Common is no longer supported on Linux, this only works on .NET 6 and requires setting the System.Drawing.EnableUnixSupport runtime configuration switch.

To install libgdiplus, run:

apk add libgdiplus

Next steps