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

Build .NET container images with Tekton

April 28, 2026
Tom Deseyn
Related topics:
.NETContainersDeveloper toolsDevOpsKubernetes
Related products:
Red Hat OpenShiftRed Hat Quay

    Tekton is a Kubernetes-native CI/CD framework that lets you define pipelines as Kubernetes resources. If you're using Tekton to build and deploy .NET applications, the dotnet-publish-image task lets you build and push container images directly using the .NET SDK without writing a Dockerfile.

    In this post, we'll walk through setting up a minimal Tekton pipeline that clones a .NET application from Git, builds a container image, and pushes it to quay.io.

    How the task works

    The dotnet-publish-image Tekton task uses .NET's built-in container publishing support to build and push container images. This means no Dockerfile or separate build tool is required.

    The task takes a few key parameters:

    • SDK_IMAGE: The .NET SDK image to use for building (for example, registry.access.redhat.com/dotnet/sdk:10.0).
    • PROJECT: Path to the .csproj file in the source workspace.
    • IMAGE_NAME: The target image repository.
    • BASE_IMAGE (optional): The base image for the application container. When the tag is omitted, it is inferred from the project's target framework.

    By default, the .NET SDK uses Microsoft's base images. To use Red Hat's .NET container images instead, set BASE_IMAGE to the appropriate image for your application type. For example, for ASP.NET Core applications use registry.access.redhat.com/dotnet/aspnet. For non-web applications use registry.access.redhat.com/dotnet/runtime.

    Install the tasks

    Our pipeline uses two tasks: git-clone to fetch the source code and dotnet-publish-image to build and push the container image. Install them using the Tekton CLI:

    tkn hub install task git-clone
    tkn hub install task dotnet-publish-image --type artifact --from redhat-tekton-tasks

    Set up the image repository

    We will push our example application to quay.io using a robot account. First, create a new repository at quay.io (for example, s2i-dotnetcore-ex).

    Next, create a robot account and grant it Write permission on the repository.

    Once that's in place, create a Kubernetes Secret with the robot account credentials. Note that the username for a robot account is your quay.io username prefixed to the robot name (e.g., myuser+myrobot):

    kubectl create secret docker-registry quay-credentials \
      --docker-server=quay.io \
      --docker-username="<username>+<robot-name>" \
      --docker-password="<robot-token>"

    Finally, link the secret to the pipeline service account so Tekton can provide it to all pipeline tasks:

    oc secret link pipeline quay-credentials
    # or: kubectl patch serviceaccount pipeline -p '{"secrets": [{"name": "quay-credentials"}]}'

    Alternatively, instead of linking the secret to the ServiceAccount, you can pass the credentials directly to the dotnet-publish-image task using its optional dockerconfig workspace.

    The pipeline

    Here's a minimal pipeline that clones the s2i-dotnetcore-ex example application and builds a container image using Red Hat's .NET 10 SDK and ASP.NET Core runtime images:

    apiVersion: tekton.dev/v1
    kind: Pipeline
    metadata:
      name: dotnet-build-image
    spec:
      params:
        - name: git-url
          type: string
          description: Git repository URL.
        - name: image-name
          type: string
          description: Target image repository.
      workspaces:
        - name: source
      tasks:
        - name: clone
          taskRef:
            name: git-clone
          params:
            - name: url
              value: $(params.git-url)
          workspaces:
            - name: output
              workspace: source
        - name: build-image
          runAfter:
            - clone
          taskRef:
            name: dotnet-publish-image
          params:
            - name: SDK_IMAGE
              value: registry.access.redhat.com/dotnet/sdk:10.0
            - name: PROJECT
              value: app/app.csproj
            - name: IMAGE_NAME
              value: $(params.image-name)
            - name: BASE_IMAGE
              value: registry.access.redhat.com/dotnet/aspnet
          workspaces:
            - name: source
              workspace: source

    This pipeline has two tasks:

    1. clone fetches the source code from Git using the git-clone task.
    2. build-image builds and pushes the container image using dotnet-publish-image.

    Run the pipeline

    Create a PipelineRun to execute the pipeline:

    apiVersion: tekton.dev/v1
    kind: PipelineRun
    metadata:
      generateName: dotnet-build-image-
    spec:
      pipelineRef:
        name: dotnet-build-image
      params:
        - name: git-url
          value: https://github.com/redhat-developer/s2i-dotnetcore-ex
        - name: image-name
          value: quay.io/<your-quay-username>/s2i-dotnetcore-ex
      workspaces:
        - name: source
          volumeClaimTemplate:
            spec:
              accessModes:
                - ReadWriteOnce
              resources:
                requests:
                  storage: 1Gi

    Now, start the pipeline run:

    kubectl create -f pipelinerun.yaml

    You can follow the progress with the Tekton CLI:

    tkn pipelinerun logs --last -f

    Once complete, the image will be available at quay.io/<your-quay-username>/s2i-dotnetcore-ex.

    The PipelineRun uses a volumeClaimTemplate for the source workspace. Tekton automatically creates a PersistentVolumeClaim for each run and cleans it up when the PipelineRun is deleted. To control how many completed runs are retained, you can configure Tekton Pruner with history-based or time-based policies—either globally, per namespace, or scoped to specific pipelines using label selectors.

    Trigger from a Git push

    With Tekton Triggers, you can run this pipeline automatically whenever code is pushed to your repository. This involves three resource types that work together:

    • An EventListener exposes an HTTP endpoint that receives webhooks. It uses a TriggerBinding to extract parameters and a TriggerTemplate to create a new PipelineRun.
    • A TriggerBinding extracts values from the incoming webhook payload — for example, the repository clone URL from a GitHub push event.
    • A TriggerTemplate defines a PipelineRun template that gets instantiated with the extracted values each time an event is received.

    To secure the endpoint, you can add a GitHub interceptor to the EventListener. The interceptor validates the webhook signature against a shared secret, ensuring only genuine GitHub events trigger the pipeline.

    Once the EventListener is deployed, Tekton Triggers creates a Service for it. You can expose it with a Route (on OpenShift) or an Ingress, and configure it as a webhook in your GitHub repository settings — selecting the push event. After that, every push to the repository will trigger a new pipeline run that builds and pushes an updated container image.

    Conclusion

    The dotnet-publish-image task provides a straightforward way to build .NET container images in Tekton pipelines. It uses the .NET SDK's built-in container support, so there's no need to write or maintain Dockerfiles. Combined with Red Hat's .NET container images, this task gives you a minimal, production-ready pipeline for building and publishing .NET application images.

    The task supports additional features beyond what we covered here, such as passing MSBuild properties and environment variables. For the full list of parameters and usage details, see the task documentation.

    Related Posts

    • How to deploy .NET applications with systemd and Podman

    • What you need to know about Red Hat's .NET container images

    • .NET 10 is now available for RHEL and OpenShift

    • .NET container troubleshooting in OpenShift 4

    • Connect a .NET app to an external PostgreSQL database

    • How to deploy .NET apps as systemd services using containers

    Recent Posts

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    • Deploy with confidence: Continuous integration and continuous delivery for agentic AI

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

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

    What’s up next?

    openshift for dotnet devs tile card

    OpenShift for .NET Developers

    Don Schenck
    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.