Entrypoint identifies the main executable; CMD supplies a default command or arguments depending on configuration. Override behavior matters for debugging and deployment.
Before you start
You should understand the difference between an image, a running container and the host. Record where a file, process or network endpoint actually lives before diagnosing a problem. Commands illustrate local experiments; adapt image names and paths to a disposable development environment.
The practical goal is to reason through this situation: An exec-form entrypoint receives arguments from the configured command. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.
Step-by-step walkthrough
Step 1: Read image configuration
Determine the executable and default arguments from ENTRYPOINT and CMD together.
Step 2: Predict override behavior
A supplied command may replace defaults while still passing through the entrypoint.
Step 3: Use deliberate diagnostics
Override the entrypoint when the image’s executable would misinterpret a shell command.
Worked scenario
An exec-form entrypoint receives arguments from the configured command.
An exec-form entrypoint runs the application, with CMD supplying its default flags. Appending sh may pass sh as an application argument rather than starting a shell. Understand that contract before debugging; shell-form behavior adds another interpretation layer and can change signal delivery.
Common mistake
Shell form can change argument handling and signal delivery.
Verify the behavior
Inspect configuration and test default execution, argument replacement and explicit entrypoint override.
Interview exercise
Run a diagnostic command.
Answer and reasoning
Understand the image’s entrypoint contract and explicitly override it when needed rather than appending unintended arguments.
Continue learning
Compare the scenario with the Docker interview questions and test your understanding with the Docker MCQs. For terminology and implementation details, consult the reference material.