1. Images & Charts
  2. dotnet-sdk
dotnet-sdk

dotnet-sdk

Dev
Updated 11 hours ago

.Net SDK Overview

Secure your stack with a hardened .Net SDK image freshly-built by Minimus. Minimus images always include the most up-to-date package version for all packages and dependencies contained in the image.


Use this image to compile your .Net project to build the most secure, vulnerability-free application possible. To build the most secure app, use a multi-stage build using the SDK image as the builder and the Runtime image as the final target container. Learn how it's done


Try It Out

First, check the version information for the .NET latest image:

docker run --rm reg.mini.dev/dotnet-sdk dotnet --info

You should expect a response with the following st:

.NET SDK:
 Version:           10.0.100
 Commit:            db1cdb71aa
 Workload version:  10.0.100-manifests.4eab3e0f
 MSBuild version:   18.0.2

Runtime Environment:
 OS Name:     minimos
 OS Version:  20241031
 OS Platform: Linux
 RID:         minimos.20241031-x64
 Base Path:   /usr/share/dotnet/sdk/10.0.100/
... 

Build a sample app

For our next test, we will use a multi-stage build using the Minimus .NET SDK and ASP.NET images to create a simple web app.

To begin, save the following two files to your project directory:

  • dotnetapp.csproj is the project file for a sample .NET web application. Link to file
  • Program.cs starts the web server for the sample .NET web application. Link to file

Next, in the same project directory, save the code below to a Dockerfile:

# -------- Build Stage --------
FROM reg.mini.dev/dotnet-sdk:latest AS build

USER root
RUN mkdir -p /dotnetapp && chown -R 1000:1000 /dotnetapp

USER 1000
WORKDIR /dotnetapp

COPY --link --chown=1000:1000 ./dotnetapp.csproj .
COPY --link --chown=1000:1000 ./Program.cs .

RUN dotnet publish --no-self-contained -c Release -o /dotnetapp/dist

# -------- Runtime Stage --------
FROM reg.mini.dev/dotnet-aspnet:latest

WORKDIR /dotnetapp

# Copy the published app from the build stage
COPY --from=build /dotnetapp/dist .

# Set the container’s entrypoint to run the web app
CMD ["dotnetapp.dll"]

Your project directory should now look like this:

project-root/
├── Dockerfile
├── dotnetapp.csproj
└── Program.cs

Note that the framework in the .csproj file should match the image version you are using. The default currently uses version 10 and framework net10.0.

Next, build and run your .NET web app. Note that the period . specifies the current directory as the build context:

docker build -t minimus-aspnet-app .
docker run minimus-aspnet-app

You should see a message such as:

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://[::]:8080
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /dotnetapp

Technical Considerations

The .Net SDK image provided by Minimus is a slim, security-hardened alternative to the public image from Docker Hub. The images are largely interchangeable, with a few differences as noted below.

.Net SDK built by Minimus:

  1. The Minimus image .NET SDK version may be different from the public image. Refer to the Microsoft .NET SDK versioning guide for more information.
  2. Runs as user app, ID 1000. The public image runs as user app, ID 1654.
  3. The following environment variables are not supported: ASPNET_VERSION, DOTNET_VERSION, DOTNET_SDK_VERSION. Drill down on the version specification tab to see the default user, listening ports, entrypoint, volumes, environment variables, etc.

The Payoff

A hardened, minimal image that will remain more secure for the long run and accrue vulnerabilities at a slower rate.


Terms & Info

Trademark

This catalog is published by Minimus. All product names, logos, and marks, other than those belonging to Minimus, shown are owned by their respective rights holders and appear here only to identify the open source software each image contains. Minimus claims no ownership of those marks and implies no affiliation with, endorsement by, certification by, or sponsorship by any rights holder.

Disclaimer

Images are provided "as-is" without warranty of any kind. "Hardened" refers to the security configuration applied at the time of build and does not constitute a guarantee of ongoing security or absence of vulnerabilities. The free tier is provided without support, SLA, or guaranteed patching timelines. Security updates may be applied to paid subscriptions before or instead of free tier images. By pulling or using any image you agree to our Terms of Use.