AZ-400 · Question #20
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 t
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
Question
Exhibits
Options
- A1
- B3
- C4
- D7
How the community answered
(61 responses)- A7% (4)
- B26% (16)
- C54% (33)
- D13% (8)
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
COPYinstruction for source files; changing it has no meaningful effect on the final image size. - Line 7 is usually
ENTRYPOINTor 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
Community Discussion
No community discussion yet for this question.

