What is the difference between CMD and ENTRYPOINT in a Dockerfile?

前端 未结 16 1706
自闭症患者
自闭症患者 2020-11-21 22:31

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 -

16条回答
  •  迷失自我
    2020-11-21 23:16

    In a nutshell:

    • CMD sets default command and/or parameters, which can be overwritten from command line when docker container runs.
    • ENTRYPOINT command and parameters will not be overwritten from command line. Instead, all command line arguments will be added after ENTRYPOINT parameters.

    If you need more details or would like to see difference on example, there is a blog post that comprehensively compare CMD and ENTRYPOINT with lots of examples - http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/

提交回复
热议问题