Skip to content

fix: merge --container-options with job container.options#6111

Open
elijahr wants to merge 1 commit into
nektos:masterfrom
axiomantic:fix/container-options-merge-job-container
Open

fix: merge --container-options with job container.options#6111
elijahr wants to merge 1 commit into
nektos:masterfrom
axiomantic:fix/container-options-merge-job-container

Conversation

@elijahr

@elijahr elijahr commented Jun 11, 2026

Copy link
Copy Markdown

--container-options was ignored for any job with a container: block — options() returned the job's YAML container.options and never looked at the CLI flag, so it only worked for jobs without a container block.

This merges them: job options first, CLI flag last, through docker's normal flag parsing (CLI scalars override, repeatable flags stack — same as compose). Jobs with no container block, or no flag, behave exactly as before.

Handy for injecting local-only options like --privileged --security-opt seccomp=unconfined without committing them to the workflow. Added tests in run_context_test.go.

When a job declares a container: block, RunContext.options() returned
only the job's YAML container.options and silently discarded the CLI
--container-options flag. The flag was therefore honored only for jobs
without a container: block, contradicting its documented purpose
("...for the job container without an options property in the job
definition").

options() now appends the CLI --container-options after the job's
interpolated container.options. act feeds the combined string to docker's
single flag parser, so scalar flags from the CLI win conflicts (last
value) and repeatable flags (--cap-add, --security-opt, -v, ...)
accumulate -- matching Docker Compose merge semantics (scalars override,
sequences concatenate). Jobs without a container: block and jobs without
the CLI flag are unaffected.

This lets operators inject local-only container options (e.g. --privileged
--security-opt seccomp=unconfined for ThreadSanitizer, which needs
personality(ADDR_NO_RANDOMIZE)) without editing the committed workflow,
even when the job pins its own image via a container: block.

Adds TestRunContextOptions covering merge ordering, the empty-options bug
case, the no-container-block and no-flag no-regression cases,
interpolation, and multi-token merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant