问题描述
我想慢慢建立一个docker镜像来满足我们的需求。我想要做的是,运行我的基本图像有单声道,然后有单声道在后台运行可执行文件。从正常的命令行,而不尝试在容器中运行它,它将看起来像:
i'm trying to slowly build up a docker image for our needs. What I want to do, is run my base image that has mono, and then have mono run an executable in the background. from the normal command line, without trying to run it in a container, it would look like:
/usr/local/bin/mono /home/crystal/Downloads/BackgroundProcesser.exe &
这很好。但是如果我尝试这样做,当我运行容器像这样:
That works fine. But if I try to do it when i run the container like so:
sudo docker run -i -t crystal/mono-base /usr/local/bin/mono /home/crystal/Downloads/BackgroundProcesser.exe &
我得到没有这样的文件或目录
。有没有办法我可以通过&
?最后,我想通过&在后台运行这个BackgroundProcessor,然后在前台运行另一个应用程序。我看到这个帖子为一个不同的解决方案,,但我想我可以运行一些东西从命令行为我们的应用程序的概念的东西证明。
I get No such file or directory
. Is there a way I can pass the &
in? Eventually, I'd like to pass the & in to run this BackgroundProcessor in the background, and then run another app in the foreground. I saw this post for a different solution, http://blog.trifork.com/2014/03/11/using-supervisor-with-docker-to-manage-processes-supporting-image-inheritance/, but I thought I could run some stuff from the command line for proof of concept stuff for our app.
推荐答案
使用-b选项将bash命令作为字符串使用:
use the -c option to bash to give it a command line as a string:
sudo docker run -i -t crystal/mono-base bash -c "/usr/local/bin/mono /home/crystal/Downloads/BackgroundProcesser.exe & /bin/bash"
并将后面的命令放到容器后不立即退出
and put something after the backgrounded command to the container doesn't immediately exit
这篇关于命令行参数到docker run的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!