nerdexam
Cisco

200-901 · Question #259

Refer to the exhibit. Which command, including arguments, is executed when the container starts?

The correct answer is A. /bin/sh -c "/bin/sleep 30 && nginx -g 'daemon off;'". The container's startup command is assembled from the Dockerfile ENTRYPOINT and CMD instructions, resulting in /bin/sh -c executing a 30-second sleep followed by nginx.

Application Deployment and Security

Question

Refer to the exhibit. Which command, including arguments, is executed when the container starts?

Exhibit

200-901 question #259 exhibit

Options

  • A/bin/sh -c "/bin/sleep 30 && nginx -g 'daemon off;'"
  • B/bin/sh -c "/bin/sleep 10 && nginx -g 'daemon off;'"
  • C/bin/bash -c "/bin/sleep 30 && nginx -g 'daemon off;'"
  • D/bin/sh -c "/bin/sleep 30" && nginx -g 'daemon off;'

How the community answered

(59 responses)
  • A
    86% (51)
  • B
    3% (2)
  • C
    8% (5)
  • D
    2% (1)

Why each option

The container's startup command is assembled from the Dockerfile ENTRYPOINT and CMD instructions, resulting in /bin/sh -c executing a 30-second sleep followed by nginx.

A/bin/sh -c "/bin/sleep 30 && nginx -g 'daemon off;'"Correct

In Docker, when ENTRYPOINT is defined as ['/bin/sh', '-c'] and CMD provides the shell command string, the runtime concatenates them so the container executes /bin/sh -c followed by that string at startup. The exhibit specifies a 30-second sleep value and the nginx daemon command, making /bin/sh -c "/bin/sleep 30 && nginx -g 'daemon off;'" the correct complete command executed when the container starts.

B/bin/sh -c "/bin/sleep 10 && nginx -g 'daemon off;'"

The sleep duration specified in the Dockerfile exhibit is 30 seconds, not 10; selecting 10 contradicts the value defined in the CMD or ENTRYPOINT instruction.

C/bin/bash -c "/bin/sleep 30 && nginx -g 'daemon off;'"

The shell interpreter defined in the exhibit is /bin/sh, not /bin/bash; /bin/bash would only be used if explicitly specified in the ENTRYPOINT instruction.

D/bin/sh -c "/bin/sleep 30" && nginx -g 'daemon off;'

This syntax incorrectly splits the command, running /bin/sh -c "/bin/sleep 30" as one process and nginx as a separate shell invocation, which does not reflect how Docker merges ENTRYPOINT and CMD into a single command.

Concept tested: Docker ENTRYPOINT and CMD container startup command assembly

Source: https://docs.docker.com/reference/dockerfile/#cmd

Topics

#Container commands#Shell scripting#Docker/Kubernetes#Nginx

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice