nerdexam
Microsoft

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

Submitted by fatema_kw· Mar 6, 2026Implement containerization and manage container images using Docker and Azure Container Registry, including optimizing Dockerfile configurations for production deployments

Question

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. How should you configure the file? To answer, drag the appropriate values to the correct targets. Each value must be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Answer:

Exhibits

AZ-400 question #205 exhibit 1
AZ-400 question #205 exhibit 2

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

#Docker#Multi-stage Builds#ASP.NET Core#Containerization

Community Discussion

No community discussion yet for this question.

Full AZ-400 Practice