Builder: Check remote when local img platform doesn't match#40629
Merged
Conversation
Member
Author
|
Any ideas how to write a test for this? |
cpuguy83
force-pushed
the
buildkit_check_img_arch
branch
from
March 6, 2020 06:34
df9e071 to
e1d9b47
Compare
This fixes an issue where if a build requests an image that already exists in Docker's image store but does not match the specified build platform, instead of building using the wrong platform go ahead and check the remote for the correct platform. Steps to reproduce issue: ```terminal $ docker pull --platform=amd64 debian:buster <output supressed> $ cat Dockerfile FROM debian:buster RUN echo hello $ docker build --platform=armhf -< Dockerfile <output supressed> ``` Without this fix, the build invokcation will build using the amd64 image since it is already tagged locally, but this is clearly not what we want. With the fix the local image is not used and instead we pull the correct image. Signed-off-by: Brian Goff <[email protected]>
cpuguy83
force-pushed
the
buildkit_check_img_arch
branch
from
March 6, 2020 06:46
e1d9b47 to
ed033ad
Compare
tonistiigi
approved these changes
Mar 18, 2020
Member
Member
Author
|
Unmarked WIP since the other PR will not have an effect on this. |
Member
|
@cpuguy83 this one we want to backport? |
Member
|
I think we shouldn't backport this. It's subtly changing the behavior and although previous was undocumented and new makes more sense it might still be somewhat surprising in a patch release. |
Member
|
👍 |
Member
Author
|
Agreed with @tonistiigi |
cpuguy83
commented
Mar 31, 2020
| img, err := is.resolveLocal(ref) | ||
| if err == nil { | ||
| return "", dt, err | ||
| if img.Architecture != opt.Platform.Architecture || img.Variant != opt.Platform.Variant || img.OS != opt.Platform.OS { |
Member
Author
There was a problem hiding this comment.
@tonistiigi Should this have checked if the img.Variant is even set?
2 tasks
Closed
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes docker/for-linux#1144
This fixes an issue where if a build requests an image that already
exists in Docker's image store but does not match the specified build
platform, instead of building using the wrong platform go ahead and
check the remote for the correct platform.
Steps to reproduce issue:
Without this fix, the build invocation will build using the amd64 image
since it is already tagged locally, but this is clearly not what we
want.
With the fix the local image is not used and instead we pull the correct
image.