Skip to main content
This guide demonstrates how to use a PodArmor .NET image to build a simple .NET application.

Pull a PodArmor .NET Image

Pull the PodArmor .NET image using the following command, with the version you want to use:
docker pull parmor.azurecr.io/dotnet/dotnet:8.0
docker pull parmor.azurecr.io/dotnet-runtime/dotnet-runtime:8.0

Create a .NET container

1

Create a .NET application container

Create a new directory mkdir dotnet-quickstart && cd dotnet-quickstart and create a Program.cs file with the following content:
Console.WriteLine("Hello, PodArmor!");
2

Create a Dockerfile

Create a Dockerfile with the following content:
FROM parmor.azurecr.io/dotnet/dotnet:8.0
WORKDIR /app
COPY Program.cs .
RUN dotnet new console -o . --force
ENTRYPOINT ["dotnet", "run"]
3

Build the Docker image

Build the Docker image using the following command:
docker build -t dotnet-quickstart .
4

Run the Docker container

Run the Docker container using the following command:
docker run dotnet-quickstart

Create a .NET runtime container

1

Initialize Project

Create a new directory mkdir dotnet-project && cd dotnet-project.Create a Program.cs file with a JSON serialization example:
using System;
using System.Text.Json;

public class Program {
    public static void Main() {
        var data = new { Message = "PodArmor Secure", Value = System.Random.Shared.Next(1, 100) };
        Console.WriteLine(JsonSerializer.Serialize(data));
    }
}
2

Create Project File

Create a dotnet-project.csproj file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
    </PropertyGroup>
</Project>
3

Create a Dockerfile

Create a Dockerfile with the following content:
FROM parmor.azurecr.io/dotnet/dotnet:8.0 AS build
WORKDIR /app
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o /out

FROM parmor.azurecr.io/dotnet-runtime/dotnet-runtime:8.0 as runtime
WORKDIR /app
COPY --from=build /out .
ENTRYPOINT ["dotnet", "dotnet-project.dll"]
4

Build the Docker image

Build the Docker image using the following command:
docker build -t dotnet-project .
5

Run the Docker container

Run the Docker container using the following command:
docker run dotnet-project