Skip to content

fix(run): keep a recreated dependency's anonymous volumes - #14358

Merged
ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/run-inherit-anonymous-volumes
Oct 20, 2026
Merged

ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/run-inherit-anonymous-volumes

Conversation

@htoyoda18

@htoyoda18 htoyoda18 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

When docker compose run recreates a dependency whose configuration changed, the new container now keeps the anonymous volumes of the old one, as docker compose up already does. Before this change the dependency got fresh, empty volumes, so a database dependency looked wiped.

Related issue

Fixes #14357

Changes made

  • pkg/compose/run.go: startDependencies now passes Inherit: true to create(). It was left unset (false), while up sets it unless --renew-anon-volumes is given and the watch rebuild always sets it. run has no --renew-anon-volumes flag, so there is nothing to opt out from.
  • pkg/e2e/compose_run_test.go and pkg/e2e/testdata/TestComposeRunInheritsAnonymousVolumes/compose.yaml: a new Scenario test. Data is written into the dependency's anonymous volume, then a config change makes run recreate the dependency, and the test checks the data is still there. The data is written by the test, not by the container, so a fresh volume cannot pass the check.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

AI tool used (if applicable)

AI Tool:

Additional context

Related: #13769. #14144 added run --no-recreate to avoid recreating a dependency. This PR fixes the data loss when the recreation does happen.

(not mandatory) A picture of a cute animal, if possible in relation to what you did

image

Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
@htoyoda18
htoyoda18 marked this pull request as ready for review October 17, 2026 20:34
@htoyoda18
htoyoda18 requested review from a team as code owners October 17, 2026 20:34
@htoyoda18
htoyoda18 requested review from glours and ndeloof October 17, 2026 20:34
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ndeloof ndeloof 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. The root cause is right (run left Inherit unset while up and watch set it), the change is scoped to the dependencies run starts, and the e2e scenario fails on main for the right reason (cat: can't open '/data/marker') and passes with the fix.

Two non-blocking nits:

  • The RunOptions.CreateOptions comment in pkg/api/api.go still says Inherit is ignored for the dependencies; it is now always true.
  • The fixture could say why init: true (so sleep infinity stops quickly) and COMPOSE_IGNORE_ORPHANS=True (second step) are there.

@ndeloof
ndeloof merged commit 4125152 into docker:main Oct 20, 2026
62 of 64 checks passed
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.

[BUG] docker compose run drops the anonymous volumes of a dependency it recreates

2 participants