-
Notifications
You must be signed in to change notification settings - Fork 18.7k
c8d/push: don't automatically pick platform if multiple candidates #48737
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
base: master
Are you sure you want to change the base?
Conversation
857418b
to
1d5fa6f
Compare
Previously, when pushing an image that contains more than a single platform, if no platform was specified and there are more than one but not all platforms available, we either - "automatically" pick the host/engine's platform, if available, or - error out if there are multiple candidates but none are the host/engine's platform. This commit drops the special handling for the case where the engine's platform image is available, instead always returning an error in the case that not all platforms are available and there are multiple candidates for pushing. Signed-off-by: Laura Brehm <laurabrehm@hey.com>
1d5fa6f
to
9d35d87
Compare
Tried some variations with this PR; notes below 😅 👉 not all of these scenarios are related to this PR, but it was purely to test these variations ❤️ 1. Pushing a multi-platform image with dangling references and a single variant present that matches the hostIn this case, we should try to push, otherwise fall back to the "pre-containerd" behavior (which pulled multi-platform images as single platform)
✅ this looks to be working as expected $ docker rmi alpine:latest localhost:5001/myimage:latest
Untagged: alpine:latest
Untagged: localhost:5001/myimage:latest
Deleted: sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
$ docker pull alpine
$ docker tag alpine localhost:5001/myimage:latest
$ docker image ls --tree localhost:5001/myimage:latest
IMAGE ID DISK USAGE CONTENT SIZE USED
localhost:5001/myimage:latest beefdbd8a1da 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
$ docker push localhost:5001/myimage:latest
The push refers to repository [localhost:5001/myimage]
cf04c63912e1: Layer already exists
latest: digest: sha256:9cee2b382fe2412cd77d5d437d15a93da8de373813621f2e4d406e3df0cf0e7c size: 528
i Info → Not all multiplatform-content is present and only the available single-platform image was pushed
sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d -> sha256:9cee2b382fe2412cd77d5d437d15a93da8de373813621f2e4d406e3df0cf0e7c
$ docker buildx imagetools inspect localhost:5001/myimage:latest
Name: localhost:5001/myimage:latest
MediaType: application/vnd.docker.distribution.manifest.v2+json
Digest: sha256:9cee2b382fe2412cd77d5d437d15a93da8de373813621f2e4d406e3df0cf0e7c 2. Pushing a multi-platform image with dangling references and a single variant present that's not the native platformℹ️ This case is similar to the above, but the available variant does not match the host. In this case, we should try to push, otherwise fall back to the "pre-containerd" behavior (which pulled multi-platform images as single platform)
✅ this looks to be working as expected $ docker rmi alpine:latest localhost:5001/myimage:latest
Untagged: alpine:latest
Untagged: localhost:5001/myimage:latest
Deleted: sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
$ docker pull --platform=linux/s390x alpine
$ docker tag alpine localhost:5001/myimage:latest
$ docker image ls --tree localhost:5001/myimage:latest
IMAGE ID DISK USAGE CONTENT SIZE USED
localhost:5001/myimage:latest beefdbd8a1da 11.9MB 3.46MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/arm64/v8 9cee2b382fe2 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 11.9MB 3.46MB
$ docker push localhost:5001/myimage:latest
The push refers to repository [localhost:5001/myimage]
df110db6acd6: Pushed
latest: digest: sha256:2b5b26e09ca2856f50ac88312348d26c1ac4b8af1df9f580e5cf465fd76e3d4d size: 528
i Info → Not all multiplatform-content is present and only the available single-platform image was pushed
sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d -> sha256:2b5b26e09ca2856f50ac88312348d26c1ac4b8af1df9f580e5cf465fd76e3d4d
$ docker buildx imagetools inspect localhost:5001/myimage:latest
Name: localhost:5001/myimage:latest
MediaType: application/vnd.docker.distribution.manifest.v2+json
Digest: sha256:2b5b26e09ca2856f50ac88312348d26c1ac4b8af1df9f580e5cf465fd76e3d4d 3. Pushing a multi-platform image with dangling references and multiple variants presentℹ️ this is the issue this PR is solving; #48731 In this case, we have a multi-platform that's incomplete (dangling references);
✅ does produce an error now (🎉) $ docker pull --platform=linux/s390x alpine
Using default tag: latest
latest: Pulling from library/alpine
df110db6acd6: Download complete
Digest: sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
Status: Image is up to date for alpine:latest
docker.io/library/alpine:latest
$ docker image ls --tree localhost:5001/myimage:latest
IMAGE ID DISK USAGE CONTENT SIZE USED
localhost:5001/myimage:latest beefdbd8a1da 25.5MB 7.55MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 11.9MB 3.46MB
$ docker push localhost:5001/myimage:latest
The push refers to repository [localhost:5001/myimage]
multiple matching manifests found but no specific platform requested
$ docker buildx imagetools inspect localhost:5001/myimage:latest
ERROR: localhost:5001/myimage:latest: not found 4. Pushing a multi-platform image with a single platform (no dangling references)In this case, we have a multi-platform that only has a single platform. The image is complete because all variants (which is only one) are present. ✅ this looks to be working as expected; the image is pushed as a multi-arch image, and preserves attestations $ echo -e 'FROM alpine\nRUN echo foo > bar.txt' | docker build --platform=linux/s390x -t localhost:5001/builtimage:latest -
$ docker image ls --tree localhost:5001/builtimage:latest
IMAGE ID DISK USAGE CONTENT SIZE USED
localhost:5001/builtimage:latest f498676c34ef 3.46MB 3.46MB
└─ linux/s390x c428486d9358 3.46MB 3.46MB
$ docker push localhost:5001/builtimage:latest
The push refers to repository [localhost:5001/builtimage]
0d5da46e1ac3: Pushed
0a3341740f0b: Pushed
df110db6acd6: Pushed
latest: digest: sha256:f498676c34ef2d98438a93a9552609c623d728f03d20d91b21ace5ea9b26092a size: 855
$ docker buildx imagetools inspect localhost:5001/builtimage:latest
Name: localhost:5001/builtimage:latest
MediaType: application/vnd.oci.image.index.v1+json
Digest: sha256:f498676c34ef2d98438a93a9552609c623d728f03d20d91b21ace5ea9b26092a
Manifests:
Name: localhost:5001/builtimage:latest@sha256:c428486d9358f3a8c515a818715f586e45a0b0ea06ada398dcaf623f8628144a
MediaType: application/vnd.oci.image.manifest.v1+json
Platform: linux/s390x
Name: localhost:5001/builtimage:latest@sha256:63edd1c26bd77894e0710af6c9169f7731b91e166f7cdb54a9f8f0631e94f6fc
MediaType: application/vnd.oci.image.manifest.v1+json
Platform: unknown/unknown
Annotations:
vnd.docker.reference.digest: sha256:c428486d9358f3a8c515a818715f586e45a0b0ea06ada398dcaf623f8628144a
vnd.docker.reference.type: attestation-manifest 5. Pushing a multi-platform image with a single platform, but specifying
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when the moby/daemon/containerd/image_push.go Lines 171 to 175 in b04246c
|
Related: #48731
- What I did
Previously, when pushing an image that contains more than a single platform, if no platform was specified and there are more than one but not all platforms available, we either
This commit drops the special handling for the case where the engine's platform image is available, instead always returning an error in the case that not all platforms are available and there are multiple candidates for pushing.
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)