AZ-400 · Question #205
Drag and Drop Question You are creating a container for an ASP.NET Core app. You need to create a Dockerfile file to build the image. The solution must ensure that the size of the image is minimized.
The correct Dockerfile uses a multi-stage build to minimize image size. The first stage uses 'mcr.microsoft.com/dotnet/sdk:5.0' as the build environment (which includes compilers and build tools), runs 'dotnet restore' to retrieve dependencies, then 'dotnet publish -c Release -o
Question
Exhibits
Options
- 1dotnet publish -c Release -o out
- 2dotnet restore
- 3mcr.microsoft.com/dotnet/aspnet:5.0
- 4mcr.microsoft.com/dotnet/sdk:5.0
Explanation
The correct Dockerfile uses a multi-stage build to minimize image size. The first stage uses 'mcr.microsoft.com/dotnet/sdk:5.0' as the build environment (which includes compilers and build tools), runs 'dotnet restore' to retrieve dependencies, then 'dotnet publish -c Release -o out' to compile and publish the optimized release output. The second stage uses 'mcr.microsoft.com/dotnet/aspnet:5.0' as the runtime-only base image (much smaller than the SDK image) and copies only the published artifacts from the first stage - this is the key to minimizing image size, as the final image excludes all SDK and build tooling.
Topics
Community Discussion
No community discussion yet for this question.

