Home / Microsoft / AZ-400 / Question 32

Prev Question
Next Question

Question 32

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.)

01 FROM microsoft/dotnet:2.1-sdk

02 COPY ./

03 RUN dotnet publish -c Release -o out

04 FROM microsoft/dotnet:2.1-sdk

05 COPY -fromF0 /out /


07 ENTRYPOINT ["dotnet", "appl.dll"]

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?



Explanation (click to expand)

Multi-stage builds (in Docker 17.05 or higher) allow you to drastically reduce the size of your final image, without struggling to reduce the number of intermediate layers and files.

With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the builYou can selectively copy artifacts from one stage to another, leaving behind everything you don't want in the final image.

References (click to expand)

Prev Question
Next Question

Load more