In dockerfile writing, entrypoint cmd can only be used once. If there are multiple entrypoint cmd commands, only the last command takes effect;
The main difference between entrypoint and CMD is that the method for passing the docker run parameter is not available;
Example:
...
CMD ["Echo"]
Run
docker run $IMAGE_ID echo carson
The command specified by CMD can beOverwriteIf the command passed by docker run is the same as the command specified by CMD, it will be overwritten;
This echo overwrites cmd ["Echo"], so the final result is: Carson
...
Entrypoint ["Echo"]
Run
docker run $IMAGE_ID echo carson
The command specified by entrypoint is only a command passed by docker run at the entry point will be passed to entrypoint, so it will not be overwritten;
Entrypoint will pass all the content after the container name as a parameter to the specified command (not overwrite the command), and this echo will be executed as a parameter, does not overwrite entrypoint ["Echo;
So the execution result is Echo Carson.
Everyone must have a question.
What is the execution sequence of the two entrypoint docker run commands?
In dockerfile, the parameter specified by entrypoint must be executed before the parameter specified by docker run;
Example:
...
Entrypoint ["Echo", "Carson"]
Run
docker run $IMAGE_ID good
It is equivalent to executing:
Echo Carson good
Run Command vs cmd command
All exist in dockerfile. Build image to execute the Run Command; execute cmd when run; CMD is the final command executed by image;
This article is from the "Siberian wolf" blog, please be sure to keep this source http://kernal.blog.51cto.com/8136890/1553182
Differences between docker entrypoint cmd