AZ-204 · Question #202
Drag and Drop Question You plan to create a Docker image that runs an ASP.NET Core application named ContosoApp. You have a setup script named setupScript.ps1 and a series of application files…
The correct answer is FROM microsoft/aspnetcore:latest; COPY . / .; WORKDIR /apps/ContosoApp; RUN powershell ./setupScript.ps1; CMD ["dotnet", "ContosoApp.dll"]. The correct Dockerfile order follows Docker's build lifecycle: first establish the base image with FROM, then COPY all files into the container, set the WORKDIR to define the working directory, RUN the setup script during the build phase, and finally define the CMD to execute…
Question
Exhibit
Answer Area
Drag items
Correct arrangement
- FROM microsoft/aspnetcore:latest
- COPY . / .
- WORKDIR /apps/ContosoApp
- RUN powershell ./setupScript.ps1
- CMD ["dotnet", "ContosoApp.dll"]
Explanation
The correct Dockerfile order follows Docker's build lifecycle: first establish the base image with FROM, then COPY all files into the container, set the WORKDIR to define the working directory, RUN the setup script during the build phase, and finally define the CMD to execute when the container starts. This sequence ensures all files are present before the working directory is set and the setup script runs, and CMD correctly defers ContosoApp.dll execution to container startup rather than build time.
Topics
Community Discussion
No community discussion yet for this question.
