简体   繁体   中英

command line arguments to docker run

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 &

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.

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

@Ulfeldt's answer works. You may want to create a script to manage your processes, as this kind of commandline will quickly get out of hand. You can also use supervisor to run multiple processes, as has been explained elsewhere .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM