docker run 的命令行参数 [英] command line arguments to docker run

查看:31
本文介绍了docker run 的命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据我们的需要慢慢构建一个 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,然后在前台运行另一个应用程序.我看到这篇文章是为了不同的解决方案,http://blog.trifork.com/2014/03/11/using-supervisor-with-docker-to-manage-processes-supporting-image-inheritance/,但我以为我可以从命令行运行一些东西来证明我们的应用程序的概念.

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.

推荐答案

使用 -c 选项 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 的命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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