Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Running a NuGet server on OpenShift

October 11, 2017
Takayoshi Tanaka
Related topics:
KubernetesContainersDevOps.NET
Related products:
Red Hat OpenShift Container PlatformRed Hat OpenShift

    When you build your .NET Core project, NuGet packages are retrieved from nuget.org by default. Sometimes, however, you might want to use a local NuGet repository. For example, you may want to:

    • use private NuGet packages, but you don't want anyone except your associates to see them.
    • cache a NuGet repository at a server near your build servers
    • leave your build server disconnected from the Internet.

    I'll explain how to set up a private NuGet server on OpenShift and how you can use this NuGet server when building your .NET Core project in OpenShift using s2i-dotnetcore.

    Set up nexus server as a private NuGet server

    Unfortunately, the OSS Microsoft NuGet.Server only runs on Windows since it requires the .NET Framework. Nexus is a cross-platform repository solution from Sonatype. The free
    OSS runs on Linux and in Linux containers. SonaType provides RHEL (and CentOS) based templates for deploying Nexus OSS on OpenShift.

    We create a nexus project and import the template:

    $ oc new-project nexus
    $ oc create -f https://raw.githubusercontent.com/sonatype/docker-rhel-nexus/master/OpenShift/nexus-rhel.json

    After creating objects, an initial build starts. It may take a long time. When the build is finished, a Nexus image is available on OpenShift. Now, we can deploy this image to OpenShift. This template includes a PVC with readwriteonce access mode and specifid size (default 2Gi). If you don't have available Peresistent Storage, please set up following the document.

    $ oc new-app --template=nexus -p APPLICATION_HOSTNAME=nexus.172.0.0.1.nip.io -p SIZE=2Gi

    Once deployment is finished, you can access the nexus server with specified hostname using your browser. You can log in as admin with default password admin123.

    nexus login

    You will find two NuGet servers under components, nuget.org-proxy and nuget-hosted.

    nexus components

    The nuget.org-proxy is a caching server of NuGet.org server. When the proxy server doesn't contain the requested NuGet package, it downloads it from NuGet server and stores it. When a stored NuGet package is requested later, the proxy server provides a stored package. No configuration is required to use the nuget.org-proxy server. Let's use this server with s2i-dotnetcore.

    copy repository url

    s2i .NET Core with nuget.org-proxy

    nuget api key
    The OpenShift s2i-dotnetcore builder has a configuration variable for specifying NuGet servers:DOTNET_RESTORE_SOURCES for a build environment variable. You can specify it when creating your app with OpenShift web console:

    build environment

    Or you can specify it when using the `oc` command,

    $ oc new-app --template=dotnet-example --name=dotnet-demo --param=APPLICATION_DOMAIN="dotnet-demo.172.0.0.1.nip.io" --param=CONTEXT_DIR="/app" --param=NAME=dotnet-demo --param=SOURCE_REPOSITORY_URL=https://github.com/redhat-developer/s2i-dotnetcore-ex.git  --param=SOURCE_REPOSITORY_REF=dotnetcore-2.0 --param=DOTNET_STARTUP_PROJECT= --param=DOTNET_RESTORE_SOURCES=http://nexus.172.0.0.1.nip.io/repository/nuget.org-proxy/

    The build will now use the local NuGet server. When the build is finished, you can find the cached NuGet packages at the nexus console.

    cached packages

    Add your private NuGet package

    When you want to use nexus server to host your private packages, you can use nuget-hosted server. You have to push your private packages to this NuGet server. To do so, a NuGet APIKey is required. To find your NuGet, click the user icon on the right in the header and select NuGet API Key

    nuget api key

    You also have to add NuGet API-Key Real to Realms in the server administrator settings. While logged in as the admin user, click the gear icon in the header, then click Realms and activate it.

    add nuget api key to realms

    Now you can push your package to NuGet server. If your package file is myawesomelibrary.nupkg, the command is as followed.

    $ dotnet nuget push -k  --source http://nexus.172.0.0.1.nip.io/repository/nuget-hosted/ myawesomelibrary.nupkg

    The Nexus console shows you packages you’ve pushed to the server.

    pushed package

    Conclusion

    We learned to setup SonaType Nexus OSS on OpenShift and how to use it as a local NuGet server for the OpenShift s2i-dotnetcore builder. If you use nexus for production, you should need to provide sufficient a storage space for nuget packages and setup user authentication.

    Last updated: September 3, 2019

    Recent Posts

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.