nerdexam
LPI

305-300 · Question #6

Which of the following statements in a Dockerfile leads to a container which outputs hello world? (Choose two.)

The correct answer is B. ENTRYPOINT [ "echo hello world" ] C. ENTRYPOINT [ "echo", "hello", "world" ]. The ENTRYPOINT instruction in a Dockerfile specifies the default command to run when a container is started from the image. The ENTRYPOINT instruction can be written in two forms: exec form and shell form. The exec form uses a JSON array to specify the command and its…

303.3 Application Security

Question

Which of the following statements in a Dockerfile leads to a container which outputs hello world? (Choose two.)

Options

  • AENTRYPOINT "echo Hello World"
  • BENTRYPOINT [ "echo hello world" ]
  • CENTRYPOINT [ "echo", "hello", "world" ]
  • DENTRYPOINT echo Hello World
  • EENTRYPOINT "echo", "Hello", "World*

How the community answered

(31 responses)
  • A
    6% (2)
  • B
    81% (25)
  • D
    3% (1)
  • E
    10% (3)

Explanation

The ENTRYPOINT instruction in a Dockerfile specifies the default command to run when a container is started from the image. The ENTRYPOINT instruction can be written in two forms: exec form and shell form. The exec form uses a JSON array to specify the command and its arguments, such as [ "executable", "param1", "param2" ]. The shell form uses a single string to specify the command and its arguments, such as "executable param1 param2". The shell form is converted to the exec form by adding /bin/sh -c to the beginning of the command. Therefore, the following statements in a Dockerfile are equivalent and will lead to a container that outputs hello ENTRYPOINT [ "echo hello world" ] ENTRYPOINT [ "/bin/sh", "-c", "echo hello world" ] ENTRYPOINT "echo hello world" ENTRYPOINT [ "echo", "hello", "world" ] ENTRYPOINT [ "/bin/sh", "-c", "echo", "hello", "world" ] ENTRYPOINT "echo hello world"

Topics

#Dockerfile#ENTRYPOINT#exec form#shell form

Community Discussion

No community discussion yet for this question.

Full 305-300 Practice