dotnet-webapi-docker
Installation
SKILL.md
Base Images
Use Microsoft's official .NET images from mcr.microsoft.com. The ASP.NET runtime image ships
a non-root app user by convention — use it instead of creating your own.
| Stage | Image | Purpose |
|---|---|---|
| Restore / Build / Publish | mcr.microsoft.com/dotnet/sdk:<version> |
Full SDK for dotnet restore, dotnet build, dotnet publish |
| Runtime (final) | mcr.microsoft.com/dotnet/aspnet:<version> |
ASP.NET Core runtime only — no SDK, no build tools |
Rules:
- Pin to a specific version tag that includes the OS variant. Prefer
-noble(Ubuntu 24.04) for compatibility or-alpinefor a smaller footprint. - The SDK image is build-stage-only — it must never be the final stage.
- Match SDK and runtime versions exactly. Never mix e.g. SDK 9 with an ASP.NET 8 runtime image.