Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 274
Crystal Avatar asked Oct 10 '14 19:10

Crystal


People also ask

Can you run docker from command line?

How to Use the docker run Command. The basic syntax for the command is: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] You can run containers from locally stored Docker images.

How do I pass a variable in docker run?

With a Command Line Argument The command used to launch Docker containers, docker run , accepts ENV variables as arguments. Simply run it with the -e flag, shorthand for --env , and pass in the key=value pair: sudo docker run -e POSTGRES_USER='postgres' -e POSTGRES_PASSWORD='password' ...

How do I pass args to ENTRYPOINT docker?

So if you want to pass the URL argument to ENTRYPOINT, you need to pass the URL alone. The reason is we have the ab command as part of the ENTRYPOINT definition. And the URL you pass in the run command will be appended to the ENTRYPOINT script. In this case, CMD instruction is not required in the Dockerfile.


1 Answers

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

like image 91
Arthur Ulfeldt Avatar answered Oct 21 '22 14:10

Arthur Ulfeldt