Dockerfile specified in the implementation of orders with ENTRYPOING and CMD What is the difference?

Such as the title, I generally use CMD to specify, such as:

FROM thelanddownunder MAINTAINER ProgrammingLife CMD ["apt-get install htop"] 

But to see some of the Dockerfile also used ENTRYPOINT specified, is the above CMD replaced by ENTRYPOINT, the back seems to specify some of the order:

 FROM thelanddownunder MAINTAINER ProgrammingLife ENTRYPOINT ["apt-get install htop"] 

Is there any difference between these two methods? In addition, there are RUN to specify the order, the syntax and the above two are not the same, such as:

 FROM thelanddownunder MAINTAINER ProgrammingLife RUN apt-get install htop ENTRYPOINT ["apt-get install vim"] 

2 Solutions collect form web for “Dockerfile specified in the implementation of orders with ENTRYPOING and CMD What is the difference?”

Running time is not the same.

RUN is running in Build, before CMD and ENTRYPOINT. Build is completed, RUN is also running, then run CMD or ENTRYPOINT.

The difference between ENTRYPOINT and CMD is the way the parameter is passed when the docker run is executed. The commands specified by the CMD can be overridden by the commands passed by the docker run. For example, if the CMD is specified,

 ... CMD ["echo"] 

Then run

 docker run CONTAINER_NAME echo foo 

Then the designated echo in the CMD will be the new designated echo coverage, so the final equivalent of running echo foo , so the final result is printed out:

 foo 

And ENTRYPOINT will be behind all the contents of the container name as a parameter passed to its specified command (not to cover the command), such as:

 ... ENTRYPOINT ["echo"] 

Then run

 docker run CONTAINER_NAME echo foo 

The echo foo after CONTAINER_NAME is passed as an argument to the echo command specified in ENTRYPOING, so it is equivalent to executing

 echo "echo foo" 

The final result is:

 echo foo 

In addition, in the Dockerfile, ENTRYPOINT specifies the parameters than the parameters specified when running docker run, such as:

 ... ENTRYPOINT ["echo", "foo"] 

carried out

 docker run CONTAINER_NAME bar 

Equivalent to execution:

 echo foo bar 

The result is:

 foo bar 

Dockerfile can only specify an ENTRYPOINT, if specified a lot, only the last one is valid.

When executing the docker run command, you can also add the -entrypoint parameter to pass the specified argument to ENTRYPOINT, for example:

 ... ENTRYPOINT ["echo","foo"] 

Then execute:

 docker run CONTAINER_NAME bar #注意没有echo 

Well, it is equivalent to the implementation of the echo foo bar , the end result is

 foo bar 

I translated a "15 Docker Tips in 15 Minutes" on dockboard.org , which included the difference between RUN, CMD and ENTRYPOINT, which you can refer to.

There is also a Docker Quicktips series, which also has a ENTRYPIONT, you can look at the connection here:
http://www.tech-d.net/2014/01/27/docker-quicktip-1-entrypoint/

We will soon be added to the dockboard.org , please pay attention to Kazakhstan.

In addition there are official documents on the entrypoint description: http://docs.docker.io/en/latest/reference/builder/#entrypoint

In the Dockerfile file, if there is ENTRYPOINT and CMD, the CMD is the ENTRYPOINT parameter. If there is no ENTRYPOINT, the CMD is the default execution instruction

Heads up! This alert needs your attention, but it's not super important.