Conversation
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>
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-disposableextension.Context
When a named volume's definition no longer matches the live Docker volume,
compose upprompts 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: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-disposableis experimental — anx-*extension, not yet a Compose Specification attribute — following the same pathx-developandx-initialSynctook before being adopted as official attributes.Closes #13807
🤖 Generated with Claude Code