Este contenido no está disponible en el idioma seleccionado.

Chapter 5. Running .NET 5.0 applications in containers


Use the ubi8/dotnet-50-runtime image to run a precompiled application inside a Linux container.

Prerequisites

  • Preconfigured containers.

    The following example uses podman.

Procedure

  1. Optional: If you are in another project’s directory and do not wish to create a nested project, return to the parent directory of the project:

    # cd ..
    Copy to Clipboard Toggle word wrap
  2. Create a new MVC project in a directory called mvc_runtime_example:

    $ dotnet new mvc --output mvc_runtime_example
    Copy to Clipboard Toggle word wrap
  3. Publish the project:

    $ dotnet publish mvc_runtime_example -f net5.0 -c Release
    Copy to Clipboard Toggle word wrap
  4. Create the Dockerfile:

    $ cat > Dockerfile <<EOF
    FROM registry.access.redhat.com/ubi8/dotnet-50-runtime
    
    ADD bin/Release/net5.0/publish/ .
    
    CMD ["dotnet", "mvc_runtime_example.dll"]
    EOF
    Copy to Clipboard Toggle word wrap
  5. Build your image:

    $ podman build -t dotnet-50-runtime-example .
    Copy to Clipboard Toggle word wrap
  6. Run your image:

    $ podman run -d -p8080:8080 dotnet-50-runtime-example
    Copy to Clipboard Toggle word wrap

Verification steps

  • View the application running in the container:

    $ xdg-open http://127.0.0.1:8080
    Copy to Clipboard Toggle word wrap
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat