microsoft/dotnet-samples
dotnet/samples
Sample images illustrating how to containerize .NET and ASP.NET Core applications
dotnetapp
(Dockerfile)docker pull mcr.microsoft.com/dotnet/samples:dotnetapp
docker pull mcr.microsoft.com/dotnet/samples:dotnetapp-chiseled
aspnetapp
(Dockerfile)docker pull mcr.microsoft.com/dotnet/samples:aspnetapp
docker pull mcr.microsoft.com/dotnet/samples:aspnetapp-chiseled
These images contain sample .NET and ASP.NET Core applications.
Watch discussions for Docker-related .NET announcements.
The .NET Docker samples show various ways to use .NET and Docker together. See Building Docker Images for .NET Applications to learn more.
You can quickly run a container with a pre-built .NET Docker image, based on the .NET console sample.
Type the following command to run a sample console application:
docker run --rm mcr.microsoft.com/dotnet/samples
You can quickly run a container with a pre-built .NET Docker image, based on the ASP.NET Core sample.
Type the following command to run a sample web application:
docker run -it --rm -p 8000:8080 --name aspnetcore_sample mcr.microsoft.com/dotnet/samples:aspnetapp
After the application starts, navigate to http://localhost:8000
in your web browser. You can also view the ASP.NET Core site running in the container from another machine with a local IP address such as http://192.168.1.18:8000
.
Note: ASP.NET Core apps (in official images) listen to port 8080 by default, starting with .NET 8. The
-p
argument in these examples maps host port8000
to container port8080
(host:container
mapping). The container will not be accessible without this mapping. ASP.NET Core can be configured to listen on a different or additional port.
See Hosting ASP.NET Core Images with Docker over HTTPS to use HTTPS with this image.
.NET container images have several variants that offer different combinations of flexibility and deployment size. The Image Variants documentation contains a summary of the image variants and their use-cases.
.NET distroless container images contain only the minimal set of packages .NET needs, with everything else removed. Due to their limited set of packages, distroless containers have a minimized security attack surface, smaller deployment sizes, and faster start-up time compared to their non-distroless counterparts. They contain the following features:
.NET offers distroless images for Azure Linux and Ubuntu (Chiseled).
.NET:
.NET Framework:
View the current tags at the Microsoft Artifact Registry portal or on GitHub.
These sample images are not intended for production use and may be subject to breaking changes or removal at any time. They are provided as a starting point for developers to experiment with and learn about .NET in a containerized environment.
.NET container images are regularly monitored for the presence of CVEs. A given image will be rebuilt to pick up fixes for a CVE when:
Please refer to the Security Policy and Container Vulnerability Workflow for more detail about what to do when a CVE is encountered in a .NET image.
docker pull mcr.microsoft.com/dotnet/samples