pants icon indicating copy to clipboard operation
pants copied to clipboard

Add support for adding arbitrary docker flags

Open kuza55 opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. Docker has a lot of different flags, most of which are not officially supported via pants, I'd like to be able to use them without needing code changes to pants.

E.g. right now I need to add --debug to my command to see some stack traces from docker. Previously I wanted to use the cache_to/from args before they were officially in pants.

I would also like to be able to setup run args, e.g. ports to forward, volumes to map, etc.

Describe the solution you'd like I'd like docker_image and pants.toml to get some extra parameters for extra_command_line_build_args to be passed to docker build and extra_command_line_run_args to be passed to docker run.

Adding formatting for putting variables (eg homedir, pants hash, etc) into args would also be helpful.

Describe alternatives you've considered Adding every flag to pants that does not need special handling seems wasteful.

kuza55 avatar Jan 19 '24 17:01 kuza55

@kaos thoughts?

benjyw avatar Jan 19 '24 19:01 benjyw

yes, this has been agreed before to be a good idea. the main issue has been to come up with the design for it that is intuitive to use. the unfortunate bit is that we have [docker].build_args which are for docker build --arg so not arbitrary args for the build step, while for docker run this already exists. at this point, probably just adding it with proper docs to get it done could be acceptable. perhaps something along the lines of [docker].build_cli_args..

[...] and extra_command_line_run_args to be passed to docker run.

This is [docker].run_args.

kaos avatar Jan 20 '24 22:01 kaos

I personally need run_args to be in the docker_image target, which I at least don't see in the docs.

kuza55 avatar Jan 21 '24 03:01 kuza55

I personally need run_args to be in the docker_image target, which I at least don't see in the docs.

Ah, right. No, it's only globally in configuration thus far. PR welcome to address these features if you're able to :)

kaos avatar Jan 21 '24 16:01 kaos

Thoughts on whether the per-target option should shadow or add to the global option?

lilatomic avatar Feb 25 '24 04:02 lilatomic