Rules_docker: Allow specifying args to containers in the BUILD file

Created on 2 Feb 2018  路  3Comments  路  Source: bazelbuild/rules_docker

Currently, if you define something like:

  go_image(
    name = "something_image",
    importpath = "unused",
    embed = embed,
    args = ["--port=8080"],
  )

then you are able to run: bazel run :something_image.binary and bazel will add the --port=8080 to the binary and run it for you.

This behavior is defined for *_binary. The documentation says "Most binary rules permit an args attribute, but where this attribute is not allowed, this fact is documented under the specific rule.".

Unfortunately, this doesn't seem to work when the container itself is built and run: the CMD and/or Entrypoint in the container specification are not updated with the specified args.

Would it be acceptable for rules_docker to respect the args parameter add it to the container arguments' in the container image?

(originally issued at https://github.com/bazelbuild/rules_go/issues/1296 )

Most helpful comment

Do you mean plumbing args from <lang>_image through to container_image's cmd parameter?

If so, +1. I prototyped it here: https://github.com/drigz/rules_docker/commit/339114bce95b5319a7ce5650fbf24f5a388da6cb but all <lang>_image rules should be changed at once to keep consistency.

All 3 comments

I think we should just do this for all of the lang_image rules.

@mattmoor that line is about docker run flags. Can you explain how does that help?

Is this feature request reasonable? I'm happy to do the legwork if you give me a few more implementation hints.

Do you mean plumbing args from <lang>_image through to container_image's cmd parameter?

If so, +1. I prototyped it here: https://github.com/drigz/rules_docker/commit/339114bce95b5319a7ce5650fbf24f5a388da6cb but all <lang>_image rules should be changed at once to keep consistency.

Was this page helpful?
0 / 5 - 0 ratings