Docker Community Forums

Share and learn in the Docker community.

Best way to run a parameterized docker container


(Diyfund) #1

I have a docker container that contains a java jar file. I am passing parameters to my jar file to get it to do different tasks. If I pass the parameters to the docker image, each time I get a new container. Is this recommended? can I reuse a container and pass in different parameters?

I run these commands many times a day, and don’t want hundreds of unneeded containers floating around.

What is the best way to handle this?

Thanks,
Eric


(Sidetracked) #2

Hi Eric,

I’m no expert, but it sounds like you are doing the right thing by passing by passing in parameters to an image file. If you don’t need the ‘exited’ containers you’ve previously run, pass the --rm option to the docker run command and they will be removed once they are done.

Regards,
Shane