Skip to content

cli/command/service: preserve mount order on service update - #7262

Closed
FrancescoCastaldi wants to merge 1 commit into
docker:masterfrom
FrancescoCastaldi:fix-7226-service-update-mount-order
Closed

cli/command/service: preserve mount order on service update#7262
FrancescoCastaldi wants to merge 1 commit into
docker:masterfrom
FrancescoCastaldi:fix-7226-service-update-mount-order

Conversation

@FrancescoCastaldi

Copy link
Copy Markdown
Contributor

- What I did

Fixed docker service update (such as with --force) so it preserves existing service mount order when no mount flags are supplied.

This prevents a subsequent identical docker stack deploy from detecting a mount-order difference and unnecessarily rolling the service again.

Fixes #7226

- How I did it

Updated updateService() in cli/command/service/update.go to call updateMounts() only when --mount-add or --mount-rm was explicitly changed (anyChanged(flags, flagMountAdd, flagMountRemove)), matching the pattern used for all other properties in updateService.

Added regression test TestUpdateServiceForcePreservesMountOrder in cli/command/service/update_test.go.

- How to verify it

go test -mod=vendor ./cli/command/service -run '^TestUpdateServiceForcePreservesMountOrder$' -count=1
go test -mod=vendor ./cli/command/service -run '^TestUpdate' -count=1
Only call updateMounts when --mount-add or --mount-rm flags were
explicitly provided. This prevents unconditional reordering of
mounts during service updates (e.g. docker service update --force),
avoiding unnecessary rollouts on subsequent docker stack deploy.

Fixes docker#7226
@thaJeztah

Copy link
Copy Markdown
Member

duplicate of #7227

While this addresses part of the issue, I think there's another issue; the mount should not be depending on order in the compose file, and be sorted by target (mount-point) instead of source.

@thaJeztah thaJeztah closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants