Este contenido no está disponible en el idioma seleccionado.

Chapter 5. Running .NET Core 3.1 applications in containers


Use the dotnet/dotnet-31-runtime-rhel7 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 netcoreapp3.1 -c Release
    Copy to Clipboard Toggle word wrap
  4. Create the Dockerfile:

    $ cat > Dockerfile <<EOF
    FROM registry.redhat.io/dotnet/dotnet-31-runtime-rhel7
    
    ADD bin/Release/netcoreapp3.1/publish/ .
    
    CMD ["dotnet", "mvc_runtime_example.dll"]
    EOF
    Copy to Clipboard Toggle word wrap
  5. Build your image:

    $ podman build -t dotnet-31-runtime-example .
    Copy to Clipboard Toggle word wrap
    Note

    If you get an error containing the message unable to retrieve auth token: invalid username/password, you need to provide credentials for the registry.redhat.io server. Use the command podman login registry.redhat.io to log in. Your credentials are typically the same as those used for the Red Hat Customer Portal.

  6. Run your image:

    $ podman run -d -p8080:8080 dotnet-31-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