Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: set remote digest when pushed with docker driver #989

Merged
merged 1 commit into from Mar 8, 2022

Conversation

crazy-max
Copy link
Member

closes #975

Set containerimage.digest with correct digest when image is pushed with moby. If containerimage.digest already exists, its value will be saved to containerimage.config.digest for backward compatibility with #980.

repro: https://github.com/crazy-max/buildx-buildkit-tests/runs/5440498633?check_suite_focus=true#step:7:153

In follow-up create the imageid output in our GitHub Action and also fix digest output. See docker/build-push-action#569

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

build/build.go Outdated
remoteDigest, err := remoteDigestWithMoby(ctx, d, pushList[0])
if err == nil && remoteDigest != "" {
if v, ok := rr.ExporterResponse[exptypes.ExporterImageDigestKey]; ok {
rr.ExporterResponse[exptypes.ExporterImageConfigDigestKey] = v
Copy link
Member

Choose a reason for hiding this comment

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

why this? Is this backward compatibility or smth? Why wouldn't ExporterImageConfigDigestKey be set already?

Copy link
Member Author

@crazy-max crazy-max Mar 8, 2022

Choose a reason for hiding this comment

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

Why wouldn't ExporterImageConfigDigestKey be set already?

As you can see in https://github.com/crazy-max/buildx-buildkit-tests/runs/5458103650?check_suite_focus=true#step:7:152 (using latest stable buildx version), metadata only returns the following content when image is pushed with moby:

{
  "containerimage.digest": "sha256:1fd302965e74b804eccf7e6ab6ec1edcbd3dfa8b8371ebc7244492832c39dd81"
}

I think this is linked to the current implementation on moby: https://github.com/moby/moby/blob/327699c313f51f8062cf3affcb3746f56f3689c6/builder/builder-next/exporter/export.go#L176

Copy link
Member

Choose a reason for hiding this comment

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

Ok, we should try to fix this in moby. To make sure we only do this for the old daemons lets only set ExporterImageConfigDigestKey when no such value exists and add a comment that this is for handling older daemons that don't return ExporterImageConfigDigestKey.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
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.

None yet

2 participants