Ce contenu n'est pas disponible dans la langue sélectionnée.

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
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat