dotnet-aspnet
ASP.NET Core Web App Overview
Secure your stack with a hardened ASP.NET Core Web App 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 run a .Net web application built to be more secure and as vulnerability-free as possible. To build the most secure web app, use a multi-stage build using the SDK image as the builder and the ASP.NET image for the runtime stage.
Try It Out
For our 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.csprojis the project file for a sample .NET web application. Link to fileProgram.csstarts 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.csNote 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-appYou 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: /dotnetappTechnical Considerations
The ASP.NET Core Web App image provided by Minimus is a slim, security-hardened alternative to the public image. The images are largely interchangeable, with a few differences as noted below.
.Net Runtime built by Minimus:
- Runs as user
app, ID 1000. The public image runs as userapp, ID 1654. - 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.
- See the risk reduction dashboard for a detailed CVE comparison over the past 30 days.
- Review the compliance report to see the default hardening and security configurations for the image.
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.