0
0
Dockerdevops~5 mins

ENTRYPOINT vs CMD difference in Docker - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the CMD instruction in a Dockerfile?
CMD sets the default command and arguments for a container. It can be overridden when running the container.
Click to reveal answer
beginner
What does the ENTRYPOINT instruction do in a Dockerfile?
ENTRYPOINT sets the main command that always runs when the container starts. It is not easily overridden.
Click to reveal answer
intermediate
How do ENTRYPOINT and CMD work together in a Dockerfile?
ENTRYPOINT defines the command to run, and CMD provides default arguments to that command. CMD arguments can be overridden at runtime.
Click to reveal answer
intermediate
If a Dockerfile has both ENTRYPOINT and CMD, and you run the container with extra arguments, what happens?
The extra arguments replace CMD arguments but are passed to ENTRYPOINT command. ENTRYPOINT command always runs.
Click to reveal answer
beginner
Which instruction is easier to override when running a Docker container: ENTRYPOINT or CMD?
CMD is easier to override by providing new arguments when running the container. ENTRYPOINT is harder to override.
Click to reveal answer
What happens if you specify both ENTRYPOINT and CMD in a Dockerfile?
ADocker throws an error
BCMD runs as the command, ENTRYPOINT is ignored
CBoth ENTRYPOINT and CMD run simultaneously
DENTRYPOINT runs as the command, CMD provides default arguments
Which Dockerfile instruction can be overridden by passing arguments to 'docker run'?
ANeither ENTRYPOINT nor CMD
BCMD
CBoth ENTRYPOINT and CMD
DENTRYPOINT
If ENTRYPOINT is set to '/bin/bash' and CMD is set to '-c "echo Hello"', what command runs by default?
A/bin/bash -c "echo Hello"
BOnly /bin/bash
COnly echo Hello
DDocker will fail to run
How can you override ENTRYPOINT when running a container?
AUse the --entrypoint flag with 'docker run'
BPass new arguments after the image name
CModify CMD in the Dockerfile
DYou cannot override ENTRYPOINT
Which instruction is best to use if you want your container to always run a specific command?
ACMD
BRUN
CENTRYPOINT
DENV
Explain the difference between ENTRYPOINT and CMD in Dockerfiles.
Think about which one is the main command and which one provides default options.
You got /4 concepts.
    Describe how ENTRYPOINT and CMD work together when both are used in a Dockerfile.
    Consider how the container runs the command with arguments.
    You got /4 concepts.