Docker:了解ENTRYPOINT和CMD说明 [英] Docker: understanding ENTRYPOINT and CMD instructions
问题描述
我想问一些关于可用于Docker文件的 ENTRYPOINT
和 CMD
的说明。 / p>
I'd like to ask some question about ENTRYPOINT
and CMD
instructions available for use in a Dockerfile.
- 提供使用
fig
将本地目录作为卷添加到容器中搬运工-撰写
。当执行了ENTRYPOINT
和CMD
指令时,
- 卷安装后还是之前?
- Providing that I'm mounting local directories as volumes in a container using
fig
ordocker-compose
. When exactly areENTRYPOINT
andCMD
instructions executed?- After the volumes were mounter or before?
推荐答案
1)ENTRYPOINT和CMD按照Dockerfile中显示的顺序执行,无论的卷安装
1) ENTRYPOINT and CMD are executed in the order they appear in the Dockerfile, regardless of the volumes mount
2)如果您有一个ENTRYPOINT启动动词,您可以传递参数
2) if you have an ENTRYPOINT launching a verb, you can pass a parameter
3)对Docker运行是有效的,但有些例子可能会澄清这一点,docker exec只是让你进入容器。
3) yes for docker run but some examples might clarify this, and docker exec just gets you inside the container
4)当集装箱启动时,CMD执行
4) CMD executes when a container is launched
5)您可以在Docker文件中使用多个CMD,但只能使用最后一个,Docker旨在运行一个进程,
5) you can use several CMD in a Dockerfile, but only the last one will be used, docker is designed to run one process,
如果你想运行几个,你将需要一些工具,如主管 http:// docs。 docker.com/articles/using_supervisord 或者runit或s6或daemontools请参阅 http://docs.docker.com / faq
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
由于CMD很容易被覆盖而不是ENTRYPOINT (除非您 docker运行--entrypoint )通常您的Dockerfile和CMD中最后一行都有ENTRYPOINT作为最后一行,实际上是可以更改
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
这篇关于Docker:了解ENTRYPOINT和CMD说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!