Differences between docker entrypoint cmd

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.