[英]Docker: understanding ENTRYPOINT and CMD instructions
I'd like to ask some question about ENTRYPOINT
and CMD
instructions available for use in a Dockerfile. 我想问一些关于可以在Dockerfile中使用的
ENTRYPOINT
和CMD
指令的问题。
fig
or docker-compose
. fig
或docker-compose
将本地目录作为卷安装在容器中。 When exactly are ENTRYPOINT
and CMD
instructions executed? ENTRYPOINT
和CMD
指令?
ENTRYPOINT
, will this script be executed each time a container is started? ENTRYPOINT
,每次启动容器时都会执行此脚本吗? ENTRYPOINT
, will all commands executed with docker run
or docker exec
be passed as arguments to this script ? ENTRYPOINT
,那么使用ENTRYPOINT
docker run
或docker exec
执行的所有命令都将作为参数传递给此脚本吗? CMD
instauctions executed? CMD
恢复? Once a container was started and volumes mounted ? CMD
in a Dockerfile? CMD
? What if I want to start a container with several processes / run severa exacutables? 1) ENTRYPOINT and CMD are executed in the order they appear in the Dockerfile, regardless of the volumes mount 1)ENTRYPOINT和CMD按它们在Dockerfile中出现的顺序执行,无论卷安装如何
2) if you have an ENTRYPOINT launching a verb, you can pass a parameter 2)如果你有ENTRYPOINT启动动词,你可以传递一个参数
3) yes for docker run but some examples might clarify this, and docker exec just gets you inside the container 3)是的,对于docker run,但是一些例子可能会澄清这一点,而docker exec只是让你进入容器
4) CMD executes when a container is launched 4)CMD在容器启动时执行
5) you can use several CMD in a Dockerfile, but only the last one will be used, docker is designed to run one process, 5)你可以在Dockerfile中使用几个CMD,但只使用最后一个,docker设计用于运行一个进程,
if you want to run several, you will need some tools such as supervisor http://docs.docker.com/articles/using_supervisord or runit or s6 or daemontools see http://docs.docker.com/faq 如果你想运行几个,你需要一些工具,如主管http://docs.docker.com/articles/using_supervisord或runit或s6或daemontools,请参阅http://docs.docker.com/faq
As CMD is easily overriden and not ENTRYPOINT (unless you docker run --entrypoint
) usually you have ENTRYPOINT as the last by one line in your Dockerfile and CMD as the last line, being in fact the parameter, that can change 由于CMD很容易被覆盖,而不是ENTRYPOINT(除非你的
docker run --entrypoint
),你的Dockerfile中最后一行是最后一行,而最后一行是CMD,实际上是参数,可以改变
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.