containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.35k stars 776 forks source link

buildah is unable to push an image for a non-default platform #5637

Open santiagorr opened 2 months ago

santiagorr commented 2 months ago

If I build an image for a non-default platform, e.g. i386 on amd64, armhf or armel on arm64, without building the image for the default platform, buildah is not able to push it. It complains because it doesn't find the default platform-image:

buildah push build-essential <registry>
Error: pushing image "build-essential" to "<registry>": no image found in image index for architecture amd64, variant "", OS linux: image not known

I can reproduce it locally with a simple Dockerfile:

FROM debian:unstable ARG ARCH=amd64 RUN apt-get update RUN apt-get -y install build-essential

and building it with:

buildah build --build-arg ARCH=i386 --platform "linux/i386" --manifest build-essential

The error comes from chooseInstance(): https://github.com/containers/image/blob/main/internal/manifest/oci_index.go#L264

Building the default platform additionally fixes the issue (I am able to push the image), but I need to avoid that.

mtrmac commented 2 months ago

Thanks for your report.

If I understand the situation right, that behavior of c/image is, on its terms, correct. buildah build --manifest … creates a multi-platform image, and then buildah push is trying to push (what the code expects to be) a single-platform image without explicitly choosing a non-default platform.

Buildah’s code must choose to trigger a multi-platform push (or, alternatively, use options that let the user choose the desired platform for a single-platform push).

I suspect that code already exists in buildah, and this is already possible, using buildah manifest push or maybe buildah push --all, but I’m not immediately sure. Anyway, transferring to Buildah for these details.

nalind commented 2 months ago

Yes, either buildah manifest push --all or podman push should push both the manifest list and the image.

santiagorr commented 2 months ago

Thanks for the answers to both of you @mtrmac, @nalind!

Yes, either buildah manifest push --all or podman push should push both the manifest list and the image.

You are right, both commands are able to push the single-non-default-platform-image, but buildah push ... or buidah push --all ... don't.

github-actions[bot] commented 1 month ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 1 month ago

@nalind Should we close this or better document the current behaviour?

nalind commented 1 month ago

Either the latter, or tweak how push works.

github-actions[bot] commented 3 weeks ago

A friendly reminder that this issue had no activity for 30 days.