Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for adding arbitrary docker flags #20440

Closed
kuza55 opened this issue Jan 19, 2024 · 5 comments · Fixed by #20607
Closed

Add support for adding arbitrary docker flags #20440

kuza55 opened this issue Jan 19, 2024 · 5 comments · Fixed by #20607
Labels
backend: Docker Docker backend-related issues enhancement

Comments

@kuza55
Copy link

kuza55 commented Jan 19, 2024

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.

@benjyw
Copy link
Contributor

benjyw commented Jan 19, 2024

@kaos thoughts?

@kaos
Copy link
Member

kaos commented Jan 20, 2024

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.

@kuza55
Copy link
Author

kuza55 commented Jan 21, 2024 via email

@kaos
Copy link
Member

kaos commented Jan 21, 2024

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 :)

@riisi riisi added the backend: Docker Docker backend-related issues label Jan 26, 2024
@lilatomic
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Docker Docker backend-related issues enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants