7
votes

Helo,

I have a java .jar file that takes a bunch of arguments as input when i run it from the terminal.I want to make a docker image and run it that contains the jar file where i can still pass the arguments for the jar file.

1
Have you already created a docker container? Your container can inherit by a container with java. Just copy your jar file on it and you can use it as on your local machine. Where do you struggle exactly? Stack Overflow is not there to solve you everything you could read up easily...M. Reif

1 Answers

8
votes

Set the jar file as your entrypoint and the args as your command

An example:

ENTRYPOINT ["/path/to/my/java.jar"]
CMD ["my", "default", "args"]

You can then override the args whenever you run the container, using:

docker run <my-docker-image> some custom args

More information here: http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/