In Dockerfiles there are two commands that look similar to me: CMD
and ENTRYPOINT
. But I guess that there is a (subtle?) difference between them -
I have read all answers and I want to summarize for better understanding at first glance like following:
Firstly, the whole command that gets executed in the container includes two parts: the command and the arguments
ENTRYPOINT defines the executable invoked when the container is started (for command)
CMD specifies the arguments that get passed to the ENTRYPOINT (for arguments)
In the Kubernetes In Action book points an important note about it. (chapter 7)
Although you can use the CMD instruction to specify the command you want to execute when the image is run, the correct way is to do it through the ENTRYPOINT instruction and to only specify the CMD if you want to define the default arguments.
You can also read this article for great explanation in a simple way