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?
✗ Incorrect
ENTRYPOINT sets the main command, and CMD provides default arguments to it.
Which Dockerfile instruction can be overridden by passing arguments to 'docker run'?
✗ Incorrect
CMD arguments can be replaced by arguments passed to 'docker run'. ENTRYPOINT is not replaced.
If ENTRYPOINT is set to '/bin/bash' and CMD is set to '-c "echo Hello"', what command runs by default?
✗ Incorrect
ENTRYPOINT is the command, CMD provides default arguments.
How can you override ENTRYPOINT when running a container?
✗ Incorrect
The --entrypoint flag lets you override ENTRYPOINT at runtime.
Which instruction is best to use if you want your container to always run a specific command?
✗ Incorrect
ENTRYPOINT ensures the command always runs when the container starts.
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.