Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jar file with arguments in docker

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.

like image 273
Abdalla Ismail Avatar asked Dec 16 '16 13:12

Abdalla Ismail


People also ask

How do you declare arguments in Dockerfile?

You can use the ARG command inside a Dockerfile to define the name of a parameter and its default value. This default value can also be overridden using a simple option with the Docker build command.

What is Docker file argument?

The ARG directive in Dockerfile defines the parameter name and defines its default value. This default value can be overridden by the --build-arg <parameter name>=<value> in the build command docker build .

Can we deploy jar file in Docker?

Installing Standards jar for Docker version 17. xx Navigate to the /ibm/b2bi/install/bin directory. Install the jar using InstallService. Run the following commands to apply configuration changes and to deploy the Standards jar. Run the exit command for the Docker container.


1 Answers

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/

like image 101
jaxxstorm Avatar answered Oct 11 '22 04:10

jaxxstorm