Skip to content

fix(config): pin type:image volume sources and pre_start hook images#13956

Open
glours wants to merge 1 commit into
docker:mainfrom
glours:fix-13827-pin-image-volume-digests
Open

fix(config): pin type:image volume sources and pre_start hook images#13956
glours wants to merge 1 commit into
docker:mainfrom
glours:fix-13827-pin-image-volume-digests

Conversation

@glours

@glours glours commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What I did
Rely on compose-go WithImagesResolved, which now resolves dependent images — type: image volume sources and pre_start hook images — with its already-digested guard, per-call memoization and sibling-service detection (compose-spec/compose-go#894, #899), rather than duplicating resolution logic CLI-side. The interpolated path gets this for free; --no-interpolate maps the raw model onto a pseudo-project keyed by service names to reuse the same resolution, and --lock-image-digests keeps type: image volumes in its output. As a side effect, compose publish now fails fast on unresolvable dependent images.

Related issue

Fixes #13827

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

@glours
glours requested review from a team as code owners July 21, 2026 16:06
@glours
glours requested a review from ndeloof July 21, 2026 16:06
@glours glours self-assigned this Jul 21, 2026

@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: 🟡 NEEDS ATTENTION

One medium-confidence finding in the new --no-interpolate code path.

Comment thread cmd/compose/config.go Outdated
@glours
glours force-pushed the fix-13827-pin-image-volume-digests branch from 89dd5fc to b5e4ddd Compare July 22, 2026 15:23
@glours
glours requested a review from docker-agent July 22, 2026 15:32

@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: 🟡 NEEDS ATTENTION

Two medium-confidence findings in the new --no-interpolate image-digest resolution path. Both are in the newly added lockModel and resolveImageDigests functions in cmd/compose/config.go.

Comment thread cmd/compose/config.go Outdated
Comment thread cmd/compose/config.go
@glours
glours force-pushed the fix-13827-pin-image-volume-digests branch from b5e4ddd to fcd9344 Compare July 22, 2026 15:45
@glours
glours requested review from Copilot and docker-agent July 22, 2026 15:45

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@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

The PR cleanly delegates image resolution for type: image volume sources and pre_start hook images to WithImagesResolved rather than duplicating logic CLI-side. The new resolveImageDigests, preStartHooks, and imageVolumes helpers in the --no-interpolate path are well-structured: both population and writeback use the same deterministic filtering functions, keeping slice indices aligned. The lockModel function correctly limits --lock-image-digests output to image/type-image-volume fields. Test coverage in config_test.go and publish_test.go covers the main scenarios.

Rely on compose-go WithImagesResolved, which now resolves dependent
images — `type: image` volume sources and pre_start hook images —
with its already-digested guard, per-call memoization and
sibling-service detection (compose-spec/compose-go#894, docker#899), rather
than duplicating resolution logic CLI-side. The interpolated path gets
this for free; --no-interpolate maps the raw model onto a
pseudo-project keyed by service names to reuse the same resolution,
and --lock-image-digests keeps type:image volumes in its output.
pre_start hooks can't be carried into the lock override (hook lists
are appended on merge), so generating a lock warns that hook images
stay unpinned there.
As a side effect, `compose publish` now fails fast on unresolvable
dependent images.

Fixes docker#13827

Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
@glours
glours force-pushed the fix-13827-pin-image-volume-digests branch from fcd9344 to 1fa3397 Compare July 23, 2026 14:02
@glours
glours requested a review from docker-agent July 23, 2026 14:36

@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

The diff refactors cmd/compose/config.go to delegate image digest resolution for type: image volume sources and pre_start hook images to compose-go's WithImagesResolved, rather than duplicating that logic CLI-side. Key correctness properties verified:

  • Index alignment between pseudo-project construction and write-back loops is guaranteed — both use the same raw service map and helper functions with unchanged length.
  • Map reference semantics are correctly used; the removed services[name] = service reassignment was redundant.
  • Hook filtering by preStartHooks is consistent between construction and write-back, preserving index alignment even for non-map entries.
  • Tests are comprehensive and cover the new code paths.

No bugs introduced by this PR.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.22222% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/compose/config.go 92.22% 5 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

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 version pinning isn't applied to image mounts

3 participants