Advertisement
Beginner .NET, Docker & Containerization

What are the official .NET Docker base images, and what's the difference between the sdk, aspnet, and runtime image variants?

Short answer

The sdk image (mcr.microsoft.com/dotnet/sdk) includes the full SDK for building and publishing applications -- large, used only in build stages.

Save .NET mock interview
Advertisement
AModel answer
The sdk image (mcr.microsoft.com/dotnet/sdk) includes the full SDK for building and publishing applications -- large, used only in build stages. The aspnet image (mcr.microsoft.com/dotnet/aspnet) includes the ASP.NET Core runtime for running web applications -- smaller, used as the final production base for web apps. The runtime image (mcr.microsoft.com/dotnet/runtime) includes just the base .NET runtime without ASP.NET Core-specific components, for non-web console/worker applications.
Example

# Building a console app: runtime is sufficient (smaller than aspnet) FROM mcr.microsoft.com/dotnet/runtime:8.0 AS final # Building a web API: needs aspnet for Kestrel, MVC, etc. FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final

Real-world example
A background worker service that processes messages and has no web endpoints uses the smaller dotnet/runtime base image instead of dotnet/aspnet, avoiding unnecessary ASP.NET Core components it will never use.
Likely follow-ups
  • What's the size difference between these base image variants?
  • What is the runtime-deps image and when would you use it instead?
Related topics