exam questions

Exam AZ-300 All Questions

View all questions & answers for the AZ-300 exam

Exam AZ-300 topic 3 question 4 discussion

Actual exam question from Microsoft's AZ-300
Question #: 4
Topic #: 3
[All AZ-300 Questions]

DRAG DROP -
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 including ContosoApp.dll.
You need to create a Dockerfile document that meets the following requirements:
✑ Call setupScript.ps1 when the container is built.
✑ Run ContosoApp.dll when the container starts.
The Dockerfile document must be created in the same folder where ContosoApp.dll and setupScript.ps1 are stored.
Which four commands should you use to develop the solution? To answer, move the appropriate commands from the list of commands to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Jt909
Highly Voted 4 years, 10 months ago
The only source I've found from MS: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-3.1 For what i recall there are subtle differences between CMD and ENTRYPOINT, but I'll choice RUN/CMD because RUN it's used to setup and executes things. This was also useful https://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/
upvoted 11 times
...
[Removed]
Most Recent 4 years, 6 months ago
I would say the last suggested step in the provided answer is correct - that is NOT to use ENTRYPOINT, although I wouldn't use it like this myself. I guess the reason why the suggested answer is correct is because of the explenation given here: https://phoenixnap.com/kb/docker-cmd-vs-entrypoint#:~:text=CMD%20is%20an%20instruction%20that,container%20with%20a%20specific%20executable. "Combine ENTRYPOINT with CMD if you need a container with a specified executable and a default parameter that can be modified easily" - and that's not what we want here. So I'd say RUN and CMD as the last step is correct.
upvoted 4 times
cloudcuckooland
4 years, 4 months ago
i'd agree with this >> running CMD["dotnet","ContosoApp.dll"] is equal to running >dotnet ContosoApp.dll which is valid and required as per the question being asked
upvoted 1 times
...
...
Prash85
4 years, 7 months ago
Consider Entrypoint as the last step.
upvoted 3 times
...
thirstylion
4 years, 7 months ago
The last instruction should be ENTRYPOINT[ ], https://code.visualstudio.com/docs/containers/quickstart-aspnet-core. So the last step should be CMD/ENTRYPOINT
upvoted 3 times
ct84
4 years, 4 months ago
yup, fully agree
upvoted 2 times
...
...
ShadowGum
4 years, 7 months ago
The answer is correct. To clarify the last step, the question states "when container is built" hence RUN/ENTRYPOINT is correct
upvoted 1 times
...
PatMan
4 years, 8 months ago
Very easy: "RUN actually runs a command and commits the result; CMD does not execute anything at build time, but specifies the intended command for the image" The command does not need to run at build time. Hence, it as to be CMD with ENTRYPOINT
upvoted 3 times
...
cdrx
4 years, 8 months ago
There is nothing in the question that states the application layout, so why should we set the workdir in the docker file ? Is this related to the dotnet way of scalfolding the apps ?
upvoted 1 times
macco455
4 years, 5 months ago
Aren't we doing this to appease: The Dockerfile document must be created in the same folder where ContosoApp.dll and setupScript.ps1 are stored. ??
upvoted 1 times
...
...
PT1
4 years, 8 months ago
Question says "✑ Call setupScript.ps1 when the container is built." ---> This is possible with 'RUN' instruction, not with 'CMD'. This is the reason last box is what it is.
upvoted 3 times
...
FailureIsnotAnOption
4 years, 11 months ago
https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image
upvoted 1 times
...
FailureIsnotAnOption
4 years, 11 months ago
I'm no expert at this, for sure. But when I look up references to this that include "dotnet" AND "contosoapp.dll" it seems that the last choice should be the CMD/Entrypoint option. Please advise.
upvoted 1 times
cloudcuckooland
4 years, 4 months ago
if the last choice was cmd/entrypoint, this would mean that when the container is run, the CMD would be passed to the entry point as a parameter. when cmd and entrypoint are used together this is how they interact. The question does not ask for powershell to be passed to the dll at startup. The given answer is correct, the RUN command will execute once at build and the CMD command is the default command when the container starts.
upvoted 5 times
tartar
4 years, 4 months ago
The given answer is correct
upvoted 1 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago