Skip to content

Conversation

@ibrahimypr
Copy link

What I did
Until now, mustRecreate logic only checked for divergence in TypeVolume mounts but ignored TypeImage mounts. This inconsistency caused containers to erroneously retain stale images even after the source image was rebuilt.

This commit introduces a new label com.docker.compose.image.mounts that tracks the digests of images used as mounts. The convergence logic is updated to verify this label, ensuring that containers are correctly recreated whenever the underlying image mount digest changes.
Related issue
Fixes #13547

@ibrahimypr ibrahimypr requested a review from a team as a code owner January 23, 2026 08:00
@ibrahimypr ibrahimypr requested review from glours and ndeloof January 23, 2026 08:00
Copy link
Contributor

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

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

I'm not a fan about using (yet another) labels for this.
As an alternative, I suggest compose could resolve digest for image used as volume source, and update service definition accordingly (comparable to docker compose config --resolve-image-digests). Doing so we get a service definition that can be compared with actual container state.

Until now, mustRecreate logic only checked for divergence in TypeVolume
mounts but ignored TypeImage mounts. This inconsistency caused containers
to erroneously retain stale images even after the source image was rebuilt.
This commit updates ensureImagesExists to resolve image volume sources to
their digests. This way, the ServiceHash (config hash) naturally changes
when the underlying image digest changes, triggering recreation via the
standard convergence logic.
Fixes docker#13547

Signed-off-by: ibrahim yapar <74625807+ibrahimypr@users.noreply.github.com>
@ibrahimypr ibrahimypr force-pushed the fix/image-mount-recreate branch from 38a9962 to 12e2cd1 Compare January 23, 2026 18:02
@ibrahimypr
Copy link
Author

Thanks for the feedback! I've updated the implementation to resolve the image digest directly in the volume source.
This way, ServiceHash naturally detects the change without needing an extra label.
Updated the tests as well.

@ibrahimypr ibrahimypr requested a review from ndeloof January 23, 2026 18:06
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] Image mount holds on to stale image even once image is removed

2 participants