DRAG DROP –
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 may 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.
Select and Place:
Correct Answer:
Box 1: mcr.microsoft.com/dotnet/sdk:5.0
The first group of lines declares from which base image we will use to build our container on top of. If the local system does not have this image already, then docker will automatically try and fetch it. The mcr.microsoft.com/dotnet/core/sdk:5.0 comes packaged with the .NET core 5.0 SDK installed, so it’s up to the task of building ASP .NET core projects targeting version 5.0
Box 2: dotnet publish -c Release -o out
COPY . ./
RUN dotnet publish -c Release -o out
RUN dotnet restore –
Box 3: mcr.microsoft.com/dotnet/aspnet:5.0
When building container images, it’s good practice to include only the production payload and its dependencies in the container image. We don’t want the .NET core SDK included in our final image because we only need the .NET core runtime, so the dockerfile is written to use a temporary container that is packaged with the SDK called build-env to build the app.