Bazel run - passing main arguments

Viewed 9750

I created an image using java_image but I would like to pass arguments to my main function (i.e. String args[]). How can I do that when I use "bazel run name_of_image" command?

2 Answers

bazel run //your:rule -- arg1 arg2 ... argN

Everything after -- is passed to the binary.

When using java_image, bazel run //my_image will only load the image into the Docker daemon, it won't run it. To run it, you should use:

docker run bazel/my_image:my_image [args]
Related