Skip to content

volumes: experimental x-disposable extension skips the recreate prompt - #14273

Open
ndeloof wants to merge 2 commits into
docker:mainfrom
ndeloof:x-disposable-volume
Open

ndeloof wants to merge 2 commits into
docker:mainfrom
ndeloof:x-disposable-volume

Conversation

@ndeloof

@ndeloof ndeloof commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

This PR lets a volume opt out of the interactive recreate confirmation when its Compose spec has drifted from the live volume, by tagging it with the experimental x-disposable extension.

Context

When a named volume's definition no longer matches the live Docker volume, compose up prompts for confirmation before recreating it, because recreation destroys the volume's data:

Volume "..." exists but doesn't match the Compose specification in the Compose file. Recreate (data will be lost)?

In CI/CD and other non-interactive workflows this prompt breaks automation. #13807 first proposed solving this with a com.docker.compose.* label, but that was rejected: labels are part of the volume spec, so adding one itself changes the spec hash and can immediately trigger the very destructive recreation it was meant to gate, and any later spec change would silently keep bypassing confirmation. What was missing was a way to say, from the Compose file itself, "this volume can be recreated without risk to the data that matters" — as suggested in the issue.

What this PR brings

A volume can now set x-disposable: true:

volumes:
  cache:
    driver: local
    driver_opts:
      type: tmpfs
      device: tmpfs
    x-disposable: true

When such a volume diverges from its live counterpart, Compose recreates it directly and logs the decision instead of prompting — while every other volume keeps the current interactive behavior unchanged. The extension carries no risk of triggering the problem it solves: it's excluded from the volume's config hash, so tagging or untagging it never itself counts as a spec change (pinned by a dedicated test). A malformed value falls back to the safe, prompt-gated path rather than aborting the whole run.

x-disposable is experimental — an x-* extension, not yet a Compose Specification attribute — following the same path x-develop and x-initialSync took before being adopted as official attributes.

Closes #13807

🤖 Generated with Claude Code

A volume tagged with x-disposable: true asserts recreating it never
loses data that matters, so a diverged volume is recreated without
the interactive confirmation prompt. The extension is excluded from
VolumeHash (Extensions carries json:"-"), so tagging or untagging a
volume never itself triggers a spec-mismatch recreation.

Closes docker#13807

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
A decode error (wrong YAML type) no longer aborts the whole
reconcile: it now logs a warning and falls back to the safe,
prompt-gated path. Also log when x-disposable actually bypasses the
confirmation, so the automatic recreation is visible in output, and
add coverage for x-disposable: false and the malformed case, plus a
regression test pinning that Extensions never affects VolumeHash.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
ndeloof requested review from a team as code owners September 29, 2026 13:42

@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

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

Add optional auto-confirm label on volumes

2 participants