Understand how CMD and ENTRYPOINT interact
BothCMDandENTRYPOINTinstructions define what command gets executed when running a container.
There are few rules that describe their co-operation.
Dockerfile should specify at least one ofCMDorENTRYPOINTcommands.ENTRYPOINTshould be defined when using the container as an executable.CMDshould be used as a way of defining default arguments for anENTRYPOINTcommand
or for executing an ad-hoc command in a container.CMDwill be overridden when running the container with alternative arguments.
The table below shows what command is executed for differentENTRYPOINT/CMDcombinations: