Skip to content

Accept platform spec on container create#40725

Merged
tiborvass merged 1 commit into
moby:masterfrom
cpuguy83:check_img_platform
May 21, 2020
Merged

Accept platform spec on container create#40725
tiborvass merged 1 commit into
moby:masterfrom
cpuguy83:check_img_platform

Conversation

@cpuguy83

Copy link
Copy Markdown
Member

This enables image lookup when creating a container to fail when the
reference exists but it is for the wrong platform. This prevents trying
to run an image for the wrong platform, as can be the case with, for
example binfmt_misc+qemu.

@cpuguy83
cpuguy83 requested review from dmcgowan and tonistiigi March 19, 2020 20:57
@cpuguy83
cpuguy83 force-pushed the check_img_platform branch 2 times, most recently from c8ad739 to 0865f85 Compare March 19, 2020 23:33
Comment thread daemon/images/image.go Outdated
Comment thread daemon/images/image.go Outdated
@cpuguy83
cpuguy83 force-pushed the check_img_platform branch 3 times, most recently from 04c8b4b to 95f59a7 Compare March 20, 2020 22:28
This enables image lookup when creating a container to fail when the
reference exists but it is for the wrong platform. This prevents trying
to run an image for the wrong platform, as can be the case with, for
example binfmt_misc+qemu.

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83
cpuguy83 force-pushed the check_img_platform branch from 95f59a7 to 7a9cb29 Compare March 20, 2020 23:10
}

// WithPlatform specifies the desired platform the image should have.
func WithPlatform(p *specs.Platform) func(*TestContainerConfig) {

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.

where is this used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's not, I added it while I was iterating on the test but ended up not needing it.

@thaJeztah

Copy link
Copy Markdown
Member

@cpuguy83 looks like this introduced a regression / change in behavior; it will now at all times print an error, even if the platform supports the other architecture (through quemu);

docker run --rm arm32v7/alpine uname -m

Unable to find image 'arm32v7/alpine:latest' locally
latest: Pulling from arm32v7/alpine
52278dd8e579: Pulling fs layer
52278dd8e579: Verifying Checksum
52278dd8e579: Download complete
52278dd8e579: Pull complete
Digest: sha256:c929c5ca1d3f793bfdd2c6d6d9210e2530f1184c0f488f514f1bb8080bb1e82b
Status: Downloaded newer image for arm32v7/alpine:latest
docker: Error response from daemon: image with reference arm32v7/alpine was found but does not match the specified platform cpu architecture: wanted: amd64, actual: arm.
See 'docker run --help

The above previously worked, but now requires the --platform flag to be set (even though the image is not multi-arch)

@thaJeztah

Copy link
Copy Markdown
Member

/cc @simonferquel

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.

4 participants