Skip to content

feat(run): --no-recreate reuses existing dependencies as-is - #14144

Merged
glours merged 1 commit into
docker:mainfrom
ndeloof:run-no-recreate
Oct 14, 2026
Merged

glours merged 1 commit into
docker:mainfrom
ndeloof:run-no-recreate

Conversation

@ndeloof

@ndeloof ndeloof commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

run starts its dependencies through the regular create path and its config-hash divergence check, with no way to opt out: any resolution difference with the command that created them recreates the dependency — destroying state a previous run built up (#13769: database losing its users). up already offers --no-recreate for exactly this; run now aligns.

The flag maps to the existing "never" recreate policy, propagated through the RunOptions.CreateOptions fields startDependencies previously dropped. Default behavior is unchanged (empty policy = "diverged"). E2E test pins both sides: default recreates a diverged dependency, --no-recreate reuses it as-is.

Closes #13769

🤖 Generated with Claude Code

@ndeloof
ndeloof requested review from a team as code owners August 27, 2026 16:01
@ndeloof
ndeloof requested a review from glours August 27, 2026 16:01

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The flag implementation is clean and correct. The flag wires properly from the CLI option through createOptions.noRecreate → recreateStrategy() / dependenciesRecreateStrategy() (both already handle noRecreate → RecreateNever), and the propagation into startDependencies via options.Recreate / options.RecreateDependencies is complete. Default behavior is unchanged. No logic errors, nil-pointer risks, or missing error handling found in the changed code.

The dependencies a one-off starts go through the regular create path
and its config-hash divergence check, with no way to opt out: any
resolution difference with the command that created them (environment,
model edit) recreates the dependency — destroying state a previous run
built up (issue docker#13769's database losing its users). up already offers
--no-recreate for exactly this; run now aligns: the flag maps to the
"never" recreate policy, propagated through the RunOptions.CreateOptions
fields that startDependencies previously dropped. Default behavior is
unchanged (empty policy = "diverged").

Closes docker#13769

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The implementation is correct. --no-recreate maps cleanly to the existing RecreateNever policy via the existing recreateStrategy()/dependenciesRecreateStrategy() helpers, and both Recreate and RecreateDependencies are propagated from RunOptions.CreateOptions into startDependencies. The E2E test covers both sides (default recreates a diverged dependency; --no-recreate preserves it). No bugs found in the added lines.

Lower-confidence findings (not posted inline)

  • [low] pkg/compose/run.go:303 — Comment says 'empty means the default diverged policy' but the actual value passed is the non-empty string "diverged" (confidence: not scored — low severity, not delegated to verifier)
  • [low] cmd/compose/run.go:415 — Comment about setting both Recreate and RecreateDependencies could clarify that RecreateDependencies covers the transitive dependency chain (confidence: not scored — low severity, not delegated to verifier)

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@glours glours left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours
glours merged commit 77f57a9 into docker:main Oct 14, 2026
119 of 121 checks passed
@ndeloof
ndeloof deleted the run-no-recreate branch October 14, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

container re-created when it shouldn't, if using docker-compose run

3 participants