Dockerfile:运行结果为否 [英] Dockerfile : RUN results in a No op

查看:266
本文介绍了Dockerfile:运行结果为否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Docker文件,其中我试图运行一个启动Java进程的deamon。



如果我将脚本嵌入Dockerfile中,像这样。 / p>

 运行myscript.sh 

当我在结果容器上运行/ bin / bash时,我看到来自jps的 no 条目。



但是,我可以轻松地将脚本嵌入到 CMD 中,在这种情况下,当我发布

  docker运行asdfg 

我看到进程开始通常情况下,



所以,我的问题是,当我们在Dockerfile 中开始一个背景异步进程时,它的副作用总是如此将被从容器中排除?

解决方案

背景过程需要从容器开始而不是图像构建开始。
所以您的脚本需要通过 CMD ENTRYPOINT



CMD ENTRYPOINT 仍然可以是一个包含多个命令的脚本。但是我想象你的情况,如果你想要几个后台进程,使用例子 supervisord 将是你最好的选择。



另外,请查看一些已经存在的 Dockerfiles 来了解它们是如何组合在一起的。


I have a Dockerfile, in which im trying to run a deamon that starts a java process.

If I embed the script in the Dockerfile, like so.

RUN myscript.sh

When I run /bin/bash on the resulting container, I see no entries from jps.

However, I can easily embed the script as CMD in which case, when i issue

docker run asdfg

I see the process start normally.

So, my question is, when we start a background async process in a Dockerfile, is it always the case that its side effects will be excluded from the container?

解决方案

Background-processes needs to be started at container-start, not image build. So your script needs to run via CMD or ENTRYPOINT.

CMD or ENTRYPOINT can still be a script, containing multiple commands. But I would imagine in your case, if you want several background processes, that using example supervisord would be your best option.

Also, check out some already existing Dockerfiles to get an idea of how it all fits together.

这篇关于Dockerfile:运行结果为否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆