Skip to content

Output correct image ID when using Docker with the containerd-snapshotter #3136

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

Merged
merged 1 commit into from
May 1, 2025

Conversation

ctalledo
Copy link
Contributor

@ctalledo ctalledo commented Apr 21, 2025

Prior to this change, the following command emits the wrong image ID when buildx uses the "docker-container" driver and Docker is configured with the containerd-snapshotter.

$ docker buildx build --load --iidfile=img.txt

$ docker run --rm "$(cat img.txt)" echo hello
docker: Error response from daemon: No such image: sha256:4ac37e81e00f242010e42f3251094e47de6100e01d25e9bd0feac6b8906976df. See 'docker run --help'.

The problem is that buildx is outputing the incorrect image ID in this scenario (it's outputing the container image config digest, instead of the container image digest used by the containerd-snapshotter).

This commit fixes this. See moby/moby#45458.

@ctalledo ctalledo marked this pull request as draft April 21, 2025 18:57
@ctalledo ctalledo force-pushed the reworked-fix-for-moby-45458 branch 3 times, most recently from 78578ba to 54d9157 Compare April 21, 2025 23:11
@tonistiigi tonistiigi requested a review from jsternberg April 21, 2025 23:27
dgst := resp[exptypes.ExporterImageDigestKey]
if v, ok := resp[exptypes.ExporterImageConfigDigestKey]; ok {
dgst = v
func getImageID(resp map[string]string, dockerUsingContainerdSnapshotter bool) string {
Copy link
Member

Choose a reason for hiding this comment

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

dockerUsingContainerdSnapshotter should be preferImageDigest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks.

@ctalledo ctalledo force-pushed the reworked-fix-for-moby-45458 branch from 54d9157 to 460e2a1 Compare April 23, 2025 17:17
@ctalledo ctalledo requested a review from tonistiigi April 23, 2025 17:38
@ctalledo
Copy link
Contributor Author

Thanks @tonistiigi for the review and comments, I've answered them, PTAL when you get a chance. Thanks again!

@ctalledo ctalledo marked this pull request as ready for review April 23, 2025 17:43
@ctalledo ctalledo force-pushed the reworked-fix-for-moby-45458 branch 5 times, most recently from ddef55c to abbd9e7 Compare May 1, 2025 21:41
@ctalledo ctalledo force-pushed the reworked-fix-for-moby-45458 branch from abbd9e7 to 7343660 Compare May 1, 2025 23:22
@ctalledo ctalledo requested a review from tonistiigi May 1, 2025 23:22
@ctalledo ctalledo force-pushed the reworked-fix-for-moby-45458 branch 2 times, most recently from 785c473 to ba3a7fb Compare May 1, 2025 23:31
…tter.

Prior to this change, the following command emits the wrong image ID when buildx
uses the "docker-container" driver and Docker is configured with the
containerd-snapshotter.

$ docker buildx build --load --iidfile=img.txt

$ docker run --rm "$(cat img.txt)" echo hello
docker: Error response from daemon: No such image: sha256:4ac37e81e00f242010e42f3251094e47de6100e01d25e9bd0feac6b8906976df.
See 'docker run --help'.

The problem is that buildx is outputing the incorrect image ID in this scenario
(it's outputing the container image config digest, instead of the container
image digest used by the containerd-snapshotter).

This commit fixes this. See moby/moby#45458.

Signed-off-by: Cesar Talledo <[email protected]>
@ctalledo ctalledo force-pushed the reworked-fix-for-moby-45458 branch from ba3a7fb to 6794078 Compare May 1, 2025 23:33
@github-actions github-actions bot removed the area/cli label May 1, 2025
@tonistiigi tonistiigi merged commit 9a48aca into docker:master May 1, 2025
138 checks passed
@ctalledo ctalledo deleted the reworked-fix-for-moby-45458 branch May 2, 2025 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants