nerdexam
MicrosoftMicrosoft

AZ-400 · Question #20

AZ-400 Question #20: Real Exam Question with Answer & Explanation

The correct answer is C: 4. Modifying line 4 matters because it is the second FROM statement in a multi-stage Dockerfile - the one that defines the final image. If it currently references mcr.microsoft.com/dotnet/core/sdk:2.2, it should be changed to mcr.microsoft.com/dotnet/core/aspnet:2.2 (or the runtime

Submitted by tom_us· Mar 6, 2026Design and implement build and release pipelines

Question

You plan to create an image that will contain a .NET Core application. You have a Dockerfile file that contains the following code. (Line numbers are included for reference only.) You need to ensure that the image is as small as possible when the image is built. Which line should you modify in the file?

Options

  • A1
  • B3
  • C4
  • D7

Explanation

Modifying line 4 matters because it is the second FROM statement in a multi-stage Dockerfile - the one that defines the final image. If it currently references mcr.microsoft.com/dotnet/core/sdk:2.2, it should be changed to mcr.microsoft.com/dotnet/core/aspnet:2.2 (or the runtime variant). The SDK image bundles compilers and build tooling that are unnecessary at runtime and add hundreds of megabytes; the aspnet image ships only the runtime, producing a much smaller deployable image.

Why the distractors are wrong:

  • Line 1 (FROM sdk:... in the build stage) must stay as the SDK image - you need build tools to compile and publish the app.
  • Line 3 is typically a COPY instruction for source files; changing it has no meaningful effect on the final image size.
  • Line 7 is usually ENTRYPOINT or a late-stage instruction; it doesn't affect which base image layers are included.

Memory tip: Think of the two-stage pattern as "build big, ship small." The first FROM is your workshop (needs all the tools); the second FROM is your delivery box (only needs the runtime). Whenever a question asks about minimizing image size, look for the second FROM and confirm it uses aspnet or runtime, not sdk.

Topics

#Docker#.NET Core#Image Optimization#Dockerfile Best Practices

Community Discussion

No community discussion yet for this question.

Full AZ-400 PracticeBrowse All AZ-400 Questions