nerdexam
CiscoCisco

350-901 · Question #7

350-901 Question #7: Real Exam Question with Answer & Explanation

The correct answer is C: ENTRYPOINT ["/bin/echo", "Test"]. To achieve the output "Test 1" when running docker run -rm devnet 1, the Dockerfile must use ENTRYPOINT ["/bin/echo", "Test"] so that the 1 passed during docker run is appended as an argument to the entrypoint command.

Application Deployment and Security

Question

Refer to the exhibit. Which additional line results in the output of Test 1 upon execution of the docker run -rm devnet 1 command in a Dockerfile with this content? FROM alpine:3.7 RUN apk add --no-cache bash

Options

  • ACMD ["/bin/echo", "Test"]
  • BRUN ["/bin/echo", "Test"]
  • CENTRYPOINT ["/bin/echo", "Test"]
  • DCMD ["/bin/echo Test"]

Explanation

To achieve the output "Test 1" when running docker run -rm devnet 1, the Dockerfile must use ENTRYPOINT ["/bin/echo", "Test"] so that the 1 passed during docker run is appended as an argument to the entrypoint command.

Common mistakes.

  • A. If CMD ["/bin/echo", "Test"] is used without an ENTRYPOINT, the arguments provided to docker run (in this case, 1) completely override the CMD instruction, leading to an attempt to execute 1 which would fail.
  • B. The RUN instruction executes commands during the Docker image build process, not when the container is run, so it would not define the runtime command for the container.
  • D. CMD ["/bin/echo Test"] uses the shell form, which would typically be overridden by docker run arguments. Even if not overridden, it would output "Test" only and not accept "1" as a separate argument to echo.

Concept tested. Dockerfile ENTRYPOINT vs CMD

Reference. https://docs.docker.com/engine/reference/builder/#entrypoint

Topics

#Dockerfile#CMD vs ENTRYPOINT#Docker Commands#Containerization

Community Discussion

No community discussion yet for this question.

Full 350-901 PracticeBrowse All 350-901 Questions