docker pull: warn when pulled single-arch image does not match --platform#42325
Conversation
c61c0ff to
d3c6134
Compare
|
@cpuguy83 @tianon @tonistiigi ptal Actually considering if this should be an error (but we can do this in a follow-up) |
There was a problem hiding this comment.
Let me fix this log, as it's mentioning manifest list which is not the case here
There was a problem hiding this comment.
Oh, actually, err already contains all info we need;
image with reference armhf/busybox was found but does not match the specified platform: wanted linux/s390x, actual: linux/arm64
We can probably just use the error
d3c6134 to
79f6265
Compare
|
Hmmm... flaky test? Not enough space on the CI machine? |
|
IMO there are enough weird edge cases in the wild to where I think this makes sense to keep as a warning (not error). 😅 Does this still warn for things that match the "vector"? (ala, |
A bit on the fence; this error/warning would only be produced when explicitly setting That said; l'd be ok with not doing that for the existing 20.10 release. If there are corner-cases where the image should be valid, but we don't handle it correctly, those are bugs we must fix.
Good question; let me give that a try on this branch |
|
Looks like docker pull --platform linux/amd64 i386/hello-world
Using default tag: latest
latest: Pulling from i386/hello-world
no matching manifest for linux/amd64 in the manifest list entries
# without --platform
docker pull i386/hello-world
Using default tag: latest
latest: Pulling from i386/hello-world
no matching manifest for linux/amd64 in the manifest list entriesInterestingly, it has from {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 525,
"digest": "sha256:cb55d8f7347376e1ba38ca740904b43c9a52f66c7d2ae1ef1a0de1bc9f40df98",
"platform": {
"architecture": "386",
"os": "linux"
}
}
]
}Pulling with either docker pull --platform=linux/386 i386/hello-world
Using default tag: latest
latest: Pulling from i386/hello-world
87e8d6e253e0: Pull complete
Digest: sha256:eb3c7d0a9879a72341421e5b0d9de21faf442201b0643823eab6786af8834d72
Status: Downloaded newer image for i386/hello-world:latest
docker.io/i386/hello-world:latest
docker rmi i386/hello-world
docker pull --platform=linux/i386 i386/hello-world
Using default tag: latest
latest: Pulling from i386/hello-world
Digest: sha256:eb3c7d0a9879a72341421e5b0d9de21faf442201b0643823eab6786af8834d72
Status: Image is up to date for i386/hello-world:latest
docker.io/i386/hello-world:latestAnd For docker pull --platform linux/arm/v7 arm32v7/hello-world:linux
linux: Pulling from arm32v7/hello-world
4ee5c797bcd7: Pull complete
Digest: sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
Status: Downloaded newer image for arm32v7/hello-world:linux
docker.io/arm32v7/hello-world:linuxAnd some other variations; docker rmi arm32v7/hello-world:linux
docker pull --platform linux/arm/v8 arm32v7/hello-world:linux
linux: Pulling from arm32v7/hello-world
Digest: sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
Status: Image is up to date for arm32v7/hello-world:linux
docker.io/arm32v7/hello-world:linux
docker rmi arm32v7/hello-world:linux
docker pull --platform linux/arm64 arm32v7/hello-world:linux
linux: Pulling from arm32v7/hello-world
4ee5c797bcd7: Pull complete
Digest: sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
Status: Downloaded newer image for arm32v7/hello-world:linux
docker.io/arm32v7/hello-world:linux
docker rmi arm32v7/hello-world:linux
docker pull --platform linux/arm/v8 arm32v7/hello-world:linux
linux: Pulling from arm32v7/hello-world
4ee5c797bcd7: Pull complete
Digest: sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
Status: Downloaded newer image for arm32v7/hello-world:linux
docker.io/arm32v7/hello-world:linux |
tianon
left a comment
There was a problem hiding this comment.
Looks like
i386/hello-worldis a multi-arch image with a single variant;
Doh, I missed that I'd referenced that one too -- you notice I fixed the arm32v7 example to use :linux explicitly for that exact reason before I posted. 😂
Thanks for the additional testing! LGTM 👍
(totally agree that warning for 20.10 is good and I won't object to error in the next release 😇)
|
CI failure seems unrelated? |
|
Triggered CI, and it's green now 👍 |
cpuguy83
left a comment
There was a problem hiding this comment.
Is the purpose here just to go the extra mile and warn that the fetched image does not match the platform?
There was a problem hiding this comment.
I'm not sure I understand this line.
There was a problem hiding this comment.
LOL, I literally took that from your PR #41873 😅
But to answer your question; err is not "local" to this if, so we need to reset it as we only want a warning to be printed, and not make the pull fail.
Alternatively I could use a local err (e.g. iErr) if you think that's better
There was a problem hiding this comment.
A local iErr makes more sense to me as it's harder to miss when changing the code in the future.
There was a problem hiding this comment.
I updated this code, and now use an early return, as well as added more comments to describe what we're doing
…form This takes the same approach as was implemented on `docker build`, where a warning is printed if `FROM --platform=...` is used (added in 3996953) Before: docker rmi armhf/busybox docker pull --platform=linux/s390x armhf/busybox Using default tag: latest latest: Pulling from armhf/busybox d34a655120f5: Pull complete Digest: sha256:8e51389cdda2158935f2b231cd158790c33ae13288c3106909324b061d24d6d1 Status: Downloaded newer image for armhf/busybox:latest docker.io/armhf/busybox:latest With this change: docker rmi armhf/busybox docker pull --platform=linux/s390x armhf/busybox Using default tag: latest latest: Pulling from armhf/busybox d34a655120f5: Pull complete Digest: sha256:8e51389cdda2158935f2b231cd158790c33ae13288c3106909324b061d24d6d1 Status: Downloaded newer image for armhf/busybox:latest WARNING: image with reference armhf/busybox was found but does not match the specified platform: wanted linux/s390x, actual: linux/arm64 docker.io/armhf/busybox:latest And daemon logs print: WARN[2021-04-26T11:19:37.153572667Z] ignoring platform mismatch on single-arch image error="image with reference armhf/busybox was found but does not match the specified platform: wanted linux/s390x, actual: linux/arm64" image=armhf/busybox When pulling without specifying `--platform, no warning is currently printed (but we can add a warning in future); docker rmi armhf/busybox docker pull armhf/busybox Using default tag: latest latest: Pulling from armhf/busybox d34a655120f5: Pull complete Digest: sha256:8e51389cdda2158935f2b231cd158790c33ae13288c3106909324b061d24d6d1 Status: Downloaded newer image for armhf/busybox:latest docker.io/armhf/busybox:latest Signed-off-by: Sebastiaan van Stijn <[email protected]>
79f6265 to
424c0eb
Compare
|
All green again; @cpuguy83 @samuelkarp ptal |
addresses docker/for-mac#5625
This takes the same approach as was implemented on
docker build, where a warningis printed if
FROM --platform=...is used (added in 3996953 / #41873)Before:
With this change:
And daemon logs print:
When pulling without specifying `--platform, no warning is currently printed (but we can add a warning in future);
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)