Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

.NET Core on Red Hat platforms

January 17, 2020
Tom Deseyn
Related topics:
.NETContainers
Related products:
Red Hat OpenShift

Share:

    In this article, we look at the various ways .NET Core is made available on Red Hat platforms. We start with an overview of the available platforms, and then show how to install .NET Core on each of them.

    Platform overview

    Let's start with the overview. If you are familiar with these platforms already, you can skip to the sections that cover specific platforms.

    Operating systems

    From an operating system point of view, we’ll look at four distributions:

    • Fedora is a community maintained distribution that moves fast. It is a great option for developers who want access to the latest development tools and the latest kernel.
    • Red Hat Enterprise Linux (RHEL) is a long-term support (LTS) distribution by Red Hat that is based on Fedora.
    • CentOS is a community maintained downstream rebuild of Red Hat Enterprise Linux.
    • CentOS Stream is a rolling preview distribution of future Red Hat Enterprise Linux versions.

    All of these distributions are Free as in Freedom, so the software is available and open for change. Fedora and CentOS have no cost (Free as in Beer). For Red Hat Enterprise Linux, you pay a support subscription to Red Hat. For development purposes, however, you can use a no-cost Red Hat Developer subscription and download Red Hat Enterprise Linux, as well as our other products and tools at no cost.

    Containers

    Most public cloud vendors support creating Red Hat Enterprise Linux- and CentOS-based virtual machines (VMs). The VMs based on RHEL are supported by Red Hat, and the VMs based on CentOS are supported by the CentOS community.

    With container technology, operating systems are now also packaged into container images. These images contain packages from the OS, but not the kernel. Red Hat provides Red Hat Enterprise Linux 7- and RHEL 8-based images. Red Hat Enterprise Linux 8-based images are based on the Universal Base Image (UBI). For Red Hat Enterprise Linux 7, some images are provided as UBI images and others as non-UBI images. The RHEL 7 non-UBI images are hosted on registry.redhat.io and require subscription credentials to be pulled. The UBI images are hosted on registry.access.redhat.com and require no subscription for download. These images may be used in production without a Red Hat subscription, on any platform. However, when the UBI images run on a Red Hat Enterprise Linux platform, subscribers get support from Red Hat. The CentOS community also provides images that are hosted on registry.centos.org.

    OpenShift

    For running container-based applications, Red Hat provides Red Hat OpenShift, which is based on Kubernetes. Kubernetes provides the core functionality for scheduling containers across multiple machines. OpenShift packages Kubernetes in a form that is usable, deployable, and maintainable. Red Hat provides a supported version of OpenShift that can be deployed on-prem and in public clouds (e.g., Azure, AWS, and GCP). Red Hat OpenShift is based on the open source, upstream okd project. To run OpenShift on your development machine, you can use Red Hat CodeReady Containers (CRC) for OpenShift 4.x, and the Red Hat Container Development Kit (CDK) for OpenShift 3.x.

    .NET Core on each platform

    Now, let's take a look at how to install .NET Core onto each Red Hat platform.

    .NET Core on Fedora

    .NET Core on Fedora is built by the Fedora .NET Special Interest Group (SIG). Because .NET Core doesn’t meet the Fedora packaging guidelines, it is distributed from a separate repository.

    To install .NET Core on Fedora, you need to enable the copr repository and install the sdk package:

    $ sudo dnf copr enable @dotnet-sig/dotnet
    $ sudo dnf install dotnet-sdk-2.1
    

    When possible, the SIG also builds preview versions of .NET Core. These preview versions are distributed from a separate repository:

    $ sudo dnf copr enable @dotnet-sig/dotnet-preview
    $ sudo dnf install dotnet-sdk-3.1
    

    For more information about running .NET Core on Fedora, see the Fedora .NET documentation.

    .NET Core on Red Hat Enterprise Linux 7 and CentOS 7

    On Red Hat Enterprise Linux 7 and CentOS 7, .NET Core versions are packaged into their own software collection (SCLs). This method of packaging allows .NET Core to include libraries that are newer than those provided by the base OS.

    To install .NET Core on Red Hat Enterprise Linux, the machine needs to be registered with the Red Hat subscription management system. Depending on the OS flavor (e.g., Server, Workstation, or HPC Compute node), you need to enable the proper .NET Core repository:

    $ sudo subscription-manager repos --enable=rhel-7-server-dotnet-rpms
    $ sudo subscription-manager repos --enable=rhel-7-workstation-dotnet-rpms
    $ sudo subscription-manager repos --enable=rhel-7-hpc-node-dotnet-rpms
    

    Next, the SCL tooling needs to be installed:

    $ sudo yum install scl-utils
    

    Now we can install a specific version of .NET Core:

    $ sudo yum install rh-dotnet21 -y
    

    To use the .NET Core SCL, we first need to enable it. For example, we can run bash in the SCL by running:

    $ scl enable rh-dotnet30 bash
    

    For more information about running .NET Core on Red Hat Enterprise Linux 7, see the .NET Core Getting Started Guides.

    .NET Core on Red Hat Enterprise Linux 8/CentOS 8

    On the newer RHEL 8, .NET Core is included in the AppStream repositories, which are enabled by default. A version of .NET Core can be installed by running:

    $ sudo dnf install dotnet-sdk-2.1
    

    For more information about running .NET Core on Red Hat Enterprise Linux 8, see the .NET Core Getting Started Guides.

    .NET Core in containers

    Two images are provided per the different .NET Core versions: a runtime image that contains everything necessary to run a .NET Core application, and an SDK image that contains the runtime plus the tooling needed to build applications.

    Table 1 shows the names of the images for .NET Core 2.1. For other versions, just change the version numbers in the name.

    Table 1: .NET Core images for version 2.1.
    Base image SDK/runtime image
    rhel7 registry.redhat.io/dotnet/dotnet-21-rhel7:2.1
    registry.redhat.io/dotnet/dotnet-21-runtime-rhel7:2.1
    centos7 registry.centos.org/dotnet/dotnet-21-centos7:latest
    registry.centos.org/dotnet/dotnet-21-runtime-centos7:latest
    ubi8 registry.access.redhat.com/ubi8/dotnet-21:2.1
    registry.access.redhat.com/ubi8/dotnet-21-runtime:2.1

    Note: Depending on the version, an image might not (yet) be available for a specific base. For example, CentOS images are made available by the CentOS community after Red Hat Enterprise Linux images are created by Red Hat.

    The following example prints out the SDK version that is available in the .NET Core 2.1 ubi8 image:

    $ podman run registry.access.redhat.com/ubi8/dotnet-21:2.1 dotnet --version
    2.1.509
    

    For more information about the .NET Core images, see the s2i-dotnetcore GitHub repo, and the .NET Core Getting Started Guides.

    .NET Core on OpenShift

    The .NET Core images provide an environment for running and building .NET Core applications. They are also compatible with OpenShift’s source-to-image (S2I) build strategy. This factor means that the OpenShift container platform can build a .NET Core application from source.

    .NET images are imported in OpenShift using the OpenShift CLI client (oc) with an image stream definition file from the s2i-dotnetcore GitHub repo. The file differs depending on the base image, as shown in Table 2.

    Table 2: .NET Core image stream definitions by base image.
    Base image Image stream definition
    rhel7 https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams.json
    centos7 https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams_centos.json
    ubi8 https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams_rhel8.json

    Retrieving the Red Hat Enterprise Linux 7 images requires authentication. Registry Authentication describes how you can set up the pull secret.

    The image streams can be imported using oc. For example, to import the ubi8-based images, run:

    $ oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams_rhel8.json
    

    Note: If there are already image streams present for .NET Core, you must use replace instead of create.

    The s2i-dotnetcore repository includes a script for installing these image streams on Windows, Linux, and macOS. See Installing for more information. This script can also create the pull secret needed for pulling the Red Hat Enterprise Linux 7 images.

    Once the image streams are installed, OpenShift can directly build and deploy an application from a Git repo, for example:

    $ oc new-app dotnet:3.1~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnetcore-3.1 --context-dir=app
    

    For more information about using .NET Core on OpenShift, see the corresponding chapter in the .NET Core Getting Started Guides.

    Conclusion

    In this article, you got an overview of the Red Hat platforms that support .NET Core, and how to install .NET Core on each of them.

    Last updated: March 26, 2023

    Recent Posts

    • How Kafka improves agentic AI

    • How to use service mesh to improve AI model security

    • How to run AI models in cloud development environments

    • How Trilio secures OpenShift virtual machines and containers

    • How to implement observability with Node.js and Llama Stack

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue