DCA · Question #50
Which statement is true?
The correct answer is A. CMD shell format uses this form ["param", param", "param"]. The CMD instruction in Dockerfiles supports an 'exec form' syntax that uses a JSON array to specify the command and its arguments.
Question
Which statement is true?
Options
- ACMD shell format uses this form ["param", param", "param"]
- BENTRYPOINT cannot be used in conjuction with CMD
- CCMD is used to run the software is the image along with any arguments
- DENTRYPOINT cannot be overriden in the "docker container run" command
How the community answered
(37 responses)- A95% (35)
- B3% (1)
- C3% (1)
Why each option
The `CMD` instruction in Dockerfiles supports an 'exec form' syntax that uses a JSON array to specify the command and its arguments.
The `CMD` instruction in a Dockerfile can be written in 'exec form', which uses a JSON array syntax like `["executable", "param1", "param2"]` to directly execute a command and its parameters. Although the option incorrectly labels this as 'shell format' (it's exec form), the described array structure is indeed a valid and recommended way to specify `CMD`.
`ENTRYPOINT` and `CMD` are designed to be used in conjunction, where `CMD` provides default arguments for the `ENTRYPOINT` command.
While `CMD` can run software and arguments if no `ENTRYPOINT` is defined, `ENTRYPOINT` is primarily used to define the main executable, with `CMD` then providing its default arguments.
`ENTRYPOINT` can be overridden at runtime using the `--entrypoint` flag in the `docker container run` command.
Concept tested: Dockerfile CMD instruction formats
Source: https://docs.docker.com/engine/reference/builder/#cmd
Topics
Community Discussion
No community discussion yet for this question.