Getting Started Guide


.NET 1.0

Installing .NET Core on Red Hat Enterprise Linux

Red Hat Customer Content Services

Abstract

The .NET Core platform is a general purpose development platform that has several key features many developers find attractive, including automatic memory management and modern programming languages. These features make it easier to build high-quality apps more efficiently. Multiple implementations of .NET are available, based on open .NET Standards that specify the fundamentals of the platform.
This availability allows Windows developers to deploy to Red Hat Enterprise Linux (RHEL) without having to learn RHEL and to expand the reach of workloads to RHEL environments. The goal is to provide a safe introduction to a new environment and culture without risk of exposure. Now users of RHEL and RHEL-based Red Hat products can develop and run .NET Core applications directly on RHEL, including Red Hat Enterprise Linux Atomic Host and OpenShift Enterprise by Red Hat. (RHEL 7 is the only version that supports .NET Core.)

This Getting Started Guide describes how to install .NET Core 1.0 on Red Hat Enterprise Linux and perform a simple Hello World! script.

  1. Install Red Hat Enterprise Linux using:

  2. Register the system by following the appropriate steps in Registering and Unregistering a System in the Red Hat Subscription Management document. You can also register the system with the following command.

    # subscription-manager register
    Copy to Clipboard Toggle word wrap
  3. Display a list of all subscriptions that are available for your system and determine the pool ID of a subscription that provides access to the .NET Core repository.

    # subscription-manager list --available
    Copy to Clipboard Toggle word wrap

    This command displays its name, unique identifier, expiration date, and other details related to it. The pool ID is listed on a line beginning with Pool Id.

  4. Attach the subscription that provides access to the .NET Core repository. Replace pool_id with the pool ID you determined in the previous step.

    # subscription-manager attach --pool=<appropriate pool ID from the above step>
    Copy to Clipboard Toggle word wrap
  5. Verify the list of subscriptions your system has currently attached.

    # subscription-manager list --consumed
    Copy to Clipboard Toggle word wrap
  6. Enable the .NET Core channel for Red Hat Enterprise Linux 7. If you are using a Workstation edition of Red Hat Enterprise Linux 7, change -server- to -workstation- in the following command.

    # subscription-manager repos --enable=rhel-7-server-dotnet-rpms
    Copy to Clipboard Toggle word wrap
  7. Install the scl tool.

    # yum install scl-utils
    Copy to Clipboard Toggle word wrap
  8. Install .NET Core 1.0 and all of its dependencies.

    # yum install rh-dotnetcore10
    Copy to Clipboard Toggle word wrap
  9. Enable the rh-dotnetcore10 collection environment.

    $ scl enable rh-dotnetcore10 bash
    Copy to Clipboard Toggle word wrap

    This command does not persist; it creates a new shell and the dotnet command is only available within that shell. If you log out, use another shell, or open up a new terminal, the enabling does not carry over. Consider permanently enabling it.

    $ source scl_source enable rh-dotnetcore10
    Copy to Clipboard Toggle word wrap
  10. Run the following command to prove the installation succeeded.

    $ dotnet --help
    Copy to Clipboard Toggle word wrap
  11. Create the following directory.

    $ mkdir hello-world
    Copy to Clipboard Toggle word wrap
  12. Navigate to the following directory.

    $ cd hello-world
    Copy to Clipboard Toggle word wrap
  13. Create a new .NET Core project.

    $ dotnet new
    Copy to Clipboard Toggle word wrap
  14. Pull the dependencies needed for the .NET Core project.

    $ dotnet restore
    Copy to Clipboard Toggle word wrap
  15. Run the .NET Core project.

    $ dotnet run
    Copy to Clipboard Toggle word wrap

Report a bug

Images are available for using .NET Core 1.0 on OpenShift Container Platform. See OpenShift Container Platform 3.3 Image Creation Guide for more details.

The .NET Core 1.0 software collection (rh-dotnetcore10) ships with the project.json build system (1.0.0-preview2 SDK). See the Known Issues in the .NET Core 1.0 Release Notes for details on installing this SDK on a non-RHEL system. Visual Studio 2017 dropped support for the project.json build system. Support for the msbuild/csproj build system will be added in the .NET Core 2.0 release.

2.1. Images

Image stream definitions for the .NET Core on Red Hat Enterprise Linux Source to Image (S2I) are now added during OpenShift Container Platform installations. The Red Hat Enterprise Linux 7 images are available through Red Hat’s subscription registry using the following command.

$ docker pull registry.access.redhat.com/dotnet/dotnetcore-10-rhel7
Copy to Clipboard Toggle word wrap

To use this image, you can either access it directly from image registries or push them into your OpenShift Container Platform Docker registry. You can also create an image stream that points to the image, either in your Docker registry or at the external location. Your OpenShift Container Platform resources can then reference the image stream definition. See OpenShift Container Platform 3.4 Guide to Using Images for more information about using images.

See OpenShift Container Platform 3.3 Installation and Configuration for more information about Red Hat OpenShift Container Platform 3.3 and .NET Core.

2.2. Configuration

The .NET Core images support a number of environment variables to control the build behavior of your .NET Core application.

Note

You must set environment variables that control build behavior in the s2i build configuration or in the .s2i/environment file to make them available to the build steps.

Expand
Variable NameDescriptionDefault

DOTNET_STARTUP_PROJECT

Used to select the project to run. This must be the folder containing project.json

Current working directory

DOTNET_PUBLISH

Used to control whether the application should be built by executing dotnet build or dotnet publish. To publish the application, set the value to true. It is recommended to publish your application.

For backwards compatibility, the default is false. In the next major release, this variable will be removed and the builder will always publish the application.

DOTNET_ASSEMBLY_NAME

Used to select the assembly to run. This must not include the .dll extension. Set this to the output assembly name specified in project.json (name, buildOptions/outputName). For project.json, the assembly name defaults to the project.json parent folder. When project.json is at the context-dir, the parent folder name will be src. So, by default, this generates a src.dll assembly. Setting DOTNET_ASSEMBLY_NAME will cause:

* The assembly to be <DOTNET_ASSEMBLY_NAME>.dll * The application sources to be in subfolder DOTNET_ASSEMBLY_NAME in the deployed container.

The name of the DOTNET_STARTUP_PROJECT folder

DOTNET_RESTORE_SOURCES

Used to specify the space-separated list of NuGet package sources used during the restore operation. This overrides all of the sources specified in the NuGet.config file.

Unset

DOTNET_NPM_TOOLS

Used to specify a list of NPM packages to install before building the application

Unset

DOTNET_TEST_PROJECTS

Used to specify the space-separated list of test projects to run. This must be folders containing project.json. dotnet test is invoked for each folder.

Unset

DOTNET_CONFIGURATION

Used to run the application in Debug or Release mode. This value should be either Release or Debug.

Release

ASPNETCORE_URLS

This variable is set to http://*:8080 to configure ASP.NET Core to use the port exposed by the image. It is not recommended to change this.

http://*:8080

HTTP_PROXY

Configures the HTTP proxy used when building and running the application

 

HTTPS_PROXY

Configures the HTTPS proxy used when building and running the application

 

NPM_MIRROR

Use a custom NPM registry mirror to download packages during the build process.

 
Note

Typical modern web applications rely on javascript tools to build the front end. The image includes npm (node package manager) to install these tools. Packages can be installed by setting DOTNET_NPM_TOOLS and by calling npm install in the build process.

An image can be used to build an application by running oc new-app against a sample repository.

$ oc new-app registry.access.redhat.com/dotnet/dotnetcore-10-rhel7~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnetcore-1.0 --context-dir=app
Copy to Clipboard Toggle word wrap

Report a bug

Chapter 3. Docker

Docker is an open source project that extends Linux containers to provide the capability to package an application with its runtime dependencies. It provides a docker command-line interface (CLI) to manage container images.

The current releases of Red Hat Enterprise Linux and Red Hat Enterprise Linux Atomic include two different versions of Docker. You can choose from:

  • docker: This package includes the version of docker that is the default for the current release of Red Hat Enterprise Linux. Install this package if you want a more stable version of docker that is compatible with the current versions of Kubernetes and OpenShift available with Red Hat Enterprise Linux.
  • docker-latest: This package includes a later version of docker that you can use if you want to work with newer features of docker. This version is not compatible with the versions of Kubernetes and OpenShift that are available with the current release of Red Hat Enterprise Linux.
Note

The docker, source-to-image packages, and running .NET Core container images are supported only on Red Hat Enterprise Linux 7 Server and Red Hat Enterprise Linux Atomic Host. You cannot install docker or run the images on Red Hat Enterprise Linux 7 Workstation or Red Hat Enterprise Linux 6 or earlier.

3.1. Linux Containers

Linux Containers is a dense application packaging and isolation technology that provides resource management, process isolation, and security on a single host. Applications are packaged with their required runtime components and deployed on a certified Red Hat Enterprise Linux host. It allows one system to run multiple secure, isolated runtimes for applications to increase system utilization.

Several components are needed for Linux containers to function correctly, and most of them are provided by the Linux kernel. Kernel namespaces ensure process isolation, and Control Groups (cgroups) are employed to control the system resources. Security-Enabled Linux (SELinux) is used to assure separation between the host and the container and also between the individual containers. Management interface forms a higher layer that interacts with the aforementioned kernel components and provides tools for construction and management of containers.

Image-based containers allow you to host multiple instances and versions of an application with minimal overhead and increased flexibility. Such containers are not tied to the host-specific configuration, which makes them portable.

When using SELinux for controlling processes within a container, make sure that any content that is volume mounted into the container is readable and potentially writable, depending on the use case. For more information, see Using Volumes with the docker Container Can Cause Problems with SELinux.

For more information on containers and container images, see the Core Concepts of the OpenShift Enterprise 3.0 Architecture, which discusses core concepts and methods related to delivering containerized applications.

3.2. Get Docker in Red Hat Enterprise Linux 7

To get an environment where you can develop Docker-formatted containers, you can install a RHEL 7 system to act as a development system as well as a container host. The docker package is stored in a Red Hat Enterprise Linux Extras repository. See the Red Hat Enterprise Linux Extras Life Cycle article for a description of support policies and life cycle information for the Red Hat Enterprise Linux Extras channel.

If you want to create Docker-formatted images or containers when using the Red Hat Enterprise Linux 7 subscription model, you must properly register and entitle the host computer on which you build them. When you use yum install within a container to add packages, the container automatically has access to entitlements available from the Red Hat Enterprise Linux 7 host so it can get RPM packages from any repository enabled on that host.

The Red Hat Enterprise Linux 7 base image container in docker-format can be found here.

Note

Currently, you must have root privilege to run the docker command in Red Hat Enterprise Linux 7 and Red Hat Enterprise Linux Atomic Host. Configuring sudo will work if you prefer not to log in directly to the root user account.

Section 1.3, Getting Docker in RHEL 7 describes how to install and register Red Hat Enterprise Linux 7 and then install docker.

Because Red Hat Enterprise Linux Atomic Host is more like an appliance than a full-featured Linux system, it is not made for you to install RPM packages or other software on. Software is added to Red Hat Enterprise Linux Atomic Host systems by running container images.

Red Hat Enterprise Linux Atomic Host has a mechanism for updating existing packages, but it does not have a mechanism for allowing users to add new packages. You should consider using a standard Red Hat Enterprise Linux 7 Server system to develop your applications so you can add a full complement of development and debugging tools. You can then use Red Hat Enterprise Linux Atomic Host to deploy your containers into a variety of virtualization and cloud environments.

You can use a Red Hat Enterprise Linux Atomic Host system to run, build, stop, start, and otherwise work with containers. Section 1.4, Getting Docker in RHEL 7 Atomic Host describes how to install and register RHEL 7 and then install Docker.

3.4. Working with Docker-formatted Containers

You can manage Docker-formatted images that are on your system in several ways, whether or not they have been run. The docker run command lets you say which command to run in a container. Once a container is running, you can stop, start, and restart it. You can remove containers you no longer need. (In fact, you probably want to.) Before you run an image, it is a good idea to investigate its contents.

See Section 1.7.5, Working with docker-formatted Containers for details on how to work with these containers.

3.5. Use .NET Core Container Images

There are two basic approaches that you can take to use the container images shipped with .NET Core:

  • using base images
  • using Source-to-Image (S2I).

3.5.1. Use Base Images

The Red Hat Enterprise Linux 7 images are available through Red Hat’s subscription registry using the following command.

# docker pull registry.access.redhat.com/dotnet/dotnetcore-10-rhel7
Copy to Clipboard Toggle word wrap

To use container images provided by Red Hat as base images in your own Dockerfile, add the following line to it.

FROM registry.access.redhat.com/dotnet/dotnetcore-10-rhel7
Copy to Clipboard Toggle word wrap

Details about working with Dockerfiles is covered in Red Hat Enterprise Linux Atomic Host 7 Getting Started with Containers.

Detailed information on Dockerfiles can be found in the Dockerfile reference document.

The following steps will guide you through creating, building, publishing and deploying a .NET Core 1.0 project as a docker image on a Red Hat Enterprise Linux 7 Server:

  1. Create a Dockerfile with the following contents:

    FROM registry.access.redhat.com/dotnet/dotnetcore-10-rhel7
    COPY hello-world /opt/app-root/src
    CMD dotnet bin/Release/netcoreapp1.0/publish/hello-world.dll
    Copy to Clipboard Toggle word wrap
  2. Create a hello-world project and publish it.

    $ scl enable rh-dotnetcore10 bash
    $ mkdir hello-world
    $ dotnet new && dotnet restore && dotnet publish c Release -r rhel.7.2-x64
    $ cd ..
    Copy to Clipboard Toggle word wrap
  3. Build the docker image and run the .NET Core 1.0 application inside it. You should see a "Hello World" message.

    # docker build -t dotnet-hello-world .
    # docker run dotnet-hello-world
    Copy to Clipboard Toggle word wrap

3.5.2. Use Source-to-Image

Source-to-Image (S2I) is a framework and a tool for writing images that use the application source code as an input and produces a new image that runs the assembled application as an output. The main advantage of using the S2I tool for building reproducible container images is the ease of use for developers.

See Section 2.2, “Configuration” for details about using environment variables to control the build behavior of your .NET Core application.

  1. To use the S2I tool on your system, ensure that the rhel-7-server-extras-rpms channel is enabled.

    # subscription-manager repos --enable=rhel-7-server-extras-rpms
    Copy to Clipboard Toggle word wrap
  2. Run the following command to install the S2I package.

    # yum install source-to-image
    Copy to Clipboard Toggle word wrap

The build process consists of the three fundamental elements that are combined into a final container image:

  • Source code of your .NET Core application
  • Builder image, a container image provided by Red Hat that supports building images using the S2I tool
  • S2I scripts that are part of the builder image.

During the build process, S2I creates a tar file that contains the source code and scripts, and then it streams that file into the builder image.

For more information on the Source-to-Image framework, see S2I Requirements.

More information about the S2I tool is available at GitHub.

  1. Build the test application from the .NET Core repository on GitHub, underneath the 1.0/test/asp-net-hello-world/ directory.

    $ sudo s2i build git://github.com/redhat-developer/s2i-dotnetcore --context-dir=1.0/test/asp-net-hello-world dotnet/dotnetcore-10-rhel7 dotnetcore10-rhel7-app
    Copy to Clipboard Toggle word wrap

    This produces a new application image: dotnetcore-10-rhel7-app.

  2. Run the resulting dotnetcore-10-rhel7-app image:

    # docker run -d -p 8080-8081:8080-8081 --name example-app dotnetcore-10-rhel7-app
    Copy to Clipboard Toggle word wrap
  3. See the app running at http://localhost:8080/.

    $ curl http://localhost:8080/
    Copy to Clipboard Toggle word wrap
  4. "Hello World" is returned.
  5. See the app running at https://localhost:8081/.

    $ curl -1 --insecure https://localhost:8081/
    Copy to Clipboard Toggle word wrap
  6. Hello World is returned.
  7. Stop the container.

    # docker stop example-app
    Copy to Clipboard Toggle word wrap
Note

See Chapter 12 in Transitioning to .NET Core on Red Hat Enterprise Linux for details on how to build, configure, and run a .NET Core image in a container.

Report a bug

Chapter 4. .NET Core Templates and Sample Apps

4.1. .NET Core Templates

The .NET Core image templates and the .NET Core images streams must first be installed. The new templates are:

Use this command to check that the image templates are installed.

$ (oc get -n openshift templates; oc get -n openshift is) | grep dotnet
Copy to Clipboard Toggle word wrap

4.2. .NET Core Sample Apps

We recommend using redhat-developer/s2i-dotnetcore-ex as the primary sample application. The new sample app provides a more exciting example than the simple "Hello World" app.

See the .NET Core repo on GitHub for more sample apps.

  1. Deploy the .NET Core sample application running on dotnet/dotnetcore-10-rhel7 using the dotnet-example template with the following command.

    $ oc new-app --template dotnet-example \
    -p DOTNET_IMAGE_STREAM_TAG=dotnet:1.0 \
    -p SOURCE_REPOSITORY_REF=dotnetcore-1.0
    Copy to Clipboard Toggle word wrap
  2. Deploy the .NET Core sample application using PostgreSQL as database with the following command.

    $ oc new-app --template=dotnet-pgsql-persistent
    Copy to Clipboard Toggle word wrap

Report a bug

Chapter 5. Reference Material

Multiple implementations of .NET Core are available, based on open .NET Standards that specify the fundamentals of the platform. See .NET Standards for more information about the standards and the Common Language Infrastructure.

See The Book of Runtime and the CoreFX framework for more information about the various Common Language Runtime libraries and framework.

See Red Hat Enterprise Linux documentation for more information about Red Hat Enterprise Linux 7.

A docker image for .NET Core is available from the Red Hat Registry at dotnet/dotnetcore-10-rhel7.

See Using Red Hat Software Collections Container Images for information about obtaining, configuring, and using container images that are shipped with Red Hat Software Collections.

Report a bug

Appendix A. Revision History

Expand
DateVersionAuthorChanges

06/24/2016

1.0

Les Williams

Original version

07/27/2016

1.0

Les Williams

Revised version number to reflect top-level version and spelled out RHEL

08/29/2016

1.0

Les Williams

Removed Step 8 and removed command outputs from Steps 9, 11, 14, 15, and 16

09/23/2016

1.0

Les Williams

Revised the link for Common Language Runtime (CLR) and added a link for Common Language Infrastructure (CLI)

11/7/2016

1.0

Les Williams

Added references to Red Hat Enterprise Linux 7 Workstation and added a link for permanently enabling rh-dotnetcore10 bash

11/15/2016

1.0

Les Williams

Replaced link with the command to permanently enabling rh-dotnetcore10 bash

12/06/2016

1.0

Les Williams

Added RHEL variants to Step 1

03/23/2017

1.0.4

Les Williams

Revised to add environment variables, installation instructions for use on OpenShift Container Platform, and Docker content

04/04/2017

1.0.4

Les Williams

Revised to add image templates and a sample app

04/26/2017

1.0.4

Les Williams

Revised to include build system support information

05/16/2017

1.0.5

Les Williams

Revised to include three new environment variables

Report a bug

Legal Notice

Copyright © 2020 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat