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

Getting started with .NET Core in Red Hat Enterprise Linux 8.1

November 25, 2019
Omair Majid
Related topics:
.NETLinux
Related products:
Red Hat Enterprise Linux

Share:

    One exciting feature in the recent release of Red Hat Enterprise Linux 8.1 is .NET Core 3.0. In this article, we will take a quick look at using .NET Core on Red Hat Enterprise Linux 8. We will cover installing .NET Core RPMs and using the RHEL-based Universal Base Image container images.

    Installing .NET Core packages on RHEL 8

    With RHEL 8, .NET Core is included in the AppStream repositories, which are enabled by default on RHEL 8 systems. At least two versions of .NET Core are already available on RHEL 8, and more will be added as they are released.

    Multiple versions of .NET Core can be installed in parallel (side-by-side). You can pick and choose which components of .NET Core (SDK, Runtime) you need and install just those. Installing a component will install all of its dependencies. For example, installing a .NET Core SDK will also install the corresponding .NET Core Runtime as well as any other additional SDK dependencies.

    You can install a specific version of the .NET Core SDK:

    dnf install dotnet-sdk-2.1
    

    Or

    dnf install dotnet-sdk-3.0
    

    In general, you can install the .NET Core SDK version x.y using:

    dnf install dotnet-sdk-x.y
    

    If you are not interested in developing .NET Core applications, rather just running them, you can skip the SDK and only install a specific version of the .NET Core Runtime. For example:

    	dnf install dotnet-runtime-2.1
    

    Or

    	dnf install dotnet-runtime-3.0
    

    Generally, you can install the .NET Core Runtime version x.y using:

    dnf install dotnet-runtime-x.y
    

    Starting with .NET Core 3.0, you also can install the ASP.NET Core Runtime, which lets you run framework-dependent ASP.NET Core applications:

    dnf install aspnetcore-runtime-3.0
    

    Running .NET Core

    Once you have installed .NET Core on RHEL 8, you can simply start using the dotnet command. To make sure .NET Core is installed, try:

    	dotnet --info
    

    That should show more information about .NET Core, including the specific components that are installed:

    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100
     Commit:    04339c3a26
    
    Runtime Environment:
     OS Name:     rhel
     OS Version:  8
     OS Platform: Linux
     RID:         rhel.8-x64
     Base Path:   /usr/lib64/dotnet/sdk/3.0.100/
    
    Host (useful for support):
      Version: 3.0.0
      Commit:  7d57652f33
    
    .NET Core SDKs installed:
      2.1.509 [/usr/lib64/dotnet/sdk]
      3.0.100 [/usr/lib64/dotnet/sdk]
    
    .NET Core runtimes installed:
      Microsoft.AspNetCore.App 3.0.0 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 2.1.13 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
      Microsoft.NETCore.App 3.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
    
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download
    

    We can now use .NET Core SDK to create, build, publish, and run a simple Hello World application:

    $ mkdir HelloWorld
    $ cd HelloWorld/
    $ dotnet new console
     
    Welcome to .NET Core 3.0!
    ---------------------
    SDK Version: 3.0.100
     
    ----------------
    Explore documentation: https://aka.ms/dotnet-docs
    Report issues and find source on GitHub: https://github.com/dotnet/core
    Find out what's new: https://aka.ms/dotnet-whats-new
    Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
    Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
    Write your first app: https://aka.ms/first-net-core-app
    --------------------------------------------------------------------------------------
    Getting ready...
    The template "Console Application" was created successfully.
     
    Processing post-creation actions...
    Running 'dotnet restore' on /HelloWorld/HelloWorld.csproj...
      Restore completed in 50.91 ms for /HelloWorld/HelloWorld.csproj.
     
    Restore succeeded.
     
    $ dotnet publish --configuration Release --runtime rhel.8-x64 --self-contained false
    Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
    Copyright (C) Microsoft Corporation. All rights reserved.
     
      Restore completed in 49.95 ms for /HelloWorld/HelloWorld.csproj.
      HelloWorld -> /HelloWorld/bin/Release/netcoreapp3.0/rhel.8-x64/HelloWorld.dll
      HelloWorld -> /HelloWorld/bin/Release/netcoreapp3.0/rhel.8-x64/publish/
    $ dotnet bin/Release/netcoreapp3.0/rhel.8-x64/publish/HelloWorld.dll  
    Hello World!
    

    See the .NET Core documentation for more information, including references, samples, and tutorials.

    Using .NET Core RHEL 8-based container images

    With Red Hat Enterprise Linux 8, .NET Core also is available in RHEL 8-based container images called Universal Base Image. You can use the container images to develop and deploy your .NET Core applications in containerized environments, such as OpenShift and Kubernetes.

    To get a .NET Core 2.1 SDK container, use:

    registry.access.redhat.com/ubi8/dotnet-21
    

    To get a .NET Core 3.0 SDK container, use:

    registry.access.redhat.com/ubi8/dotnet-30
    

    To get a .NET Core 2.1 runtime container, use:

    registry.access.redhat.com/ubi8/dotnet-21-runtime
    

    To get a .NET Core 3.0 runtime container, use:

    registry.access.redhat.com/ubi8/dotnet-30-runtime
    

    Running .NET Core containers

    You can use the .NET Core RHEL 8-based containers in your container pipelines. You can use it for deployment to cloud environments. You can also use it for building source-to-image (also called s2i) applications.

    As an example, let’s create, build, and run a Hello World-style application in a container. Create a Dockerfile that contains the following:

    FROM registry.access.redhat.com/ubi8/dotnet-30
     
    RUN dotnet --info && \
    	dotnet new console -o HelloWorld && \
    	cd HelloWorld && \
    	dotnet publish --configuration Release
     
    ENTRYPOINT dotnet HelloWorld/bin/Release/netcoreapp3.0/publish/HelloWorld.dll
    

    You can build and run this using podman or docker commands:

    $ podman build -t hello .
    STEP 1: FROM registry.access.redhat.com/ubi8/dotnet-30
    Getting image source signatures
    Copying blob d4639cd2c710 done
    Copying blob 1fa946e8e839 done
    Copying blob 340ff6d7f58c done
    Copying blob 0e8ea260d026 done               	 
    Copying config ca818f6208 done   
    Writing manifest to image destination
    Storing signatures
    STEP 2: RUN dotnet --info && 	dotnet new console -o HelloWorld && 	cd HelloWorld && 	dotnet publish --configuration Release
    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100
     Commit:	04339c3a26
     
    Runtime Environment:
     OS Name: 	rhel
     OS Version:  8
     OS Platform: Linux                                  	 
     RID:     	rhel.8-x64
     Base Path:   /usr/lib64/dotnet/sdk/3.0.100/
                                                                           	 
    Host (useful for support):
      Version: 3.0.0
      Commit:  7d57652f33
    	 
    .NET Core SDKs installed:
      3.0.100 [/usr/lib64/dotnet/sdk]
    	 
    .NET Core runtimes installed:
      Microsoft.AspNetCore.App 3.0.0 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 3.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
     
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download
    Getting ready...
    The template "Console Application" was created successfully.
     
    Processing post-creation actions...
    Running 'dotnet restore' on HelloWorld/HelloWorld.csproj...  
      Restore completed in 51.76 ms for /opt/app-root/src/HelloWorld/HelloWorld.csproj.
     
    Restore succeeded.
     
    Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
    Copyright (C) Microsoft Corporation. All rights reserved.
     
      Restore completed in 14.11 ms for /opt/app-root/src/HelloWorld/HelloWorld.csproj.
      HelloWorld -> /opt/app-root/src/HelloWorld/bin/Release/netcoreapp3.0/HelloWorld.dll
      HelloWorld -> /opt/app-root/src/HelloWorld/bin/Release/netcoreapp3.0/publish/
    164ce90cf7892154ab5a6a00f8d5f890dd26ffaabe0b6dd58c4005603fe325d4
    STEP 3: ENTRYPOINT dotnet HelloWorld/bin/Release/netcoreapp3.0/publish/HelloWorld.dll
    STEP 4: COMMIT hello
    1bd4ceedbcec15de4d99ee79ad5860d6f97031da1f4db32f7d408274262f8bec
    
    $ podman run -it hello
    Hello World!
    

    Support and lifecycle

    In general, .NET Core on Red Hat Enterprise Linux tries to follow the .NET Core lifecycle established by Microsoft. To learn more about .NET Core lifecycle on RHEL 8, visit the Red Hat Enterprise Linux 8 Application Streams Life Cycle page.

    If you run into any errors, please report it as a bug in Bugzilla.

    Last updated: January 13, 2022

    Recent Posts

    • How to use RHEL 10 as a WSL Podman machine

    • MINC: Fast, local Kubernetes with Podman Desktop & MicroShift

    • How to stay informed with Red Hat status notifications

    • Getting started with RHEL on WSL

    • llm-d: Kubernetes-native distributed inferencing

    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