buildah icon indicating copy to clipboard operation
buildah copied to clipboard

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

Open santiagorr opened this issue 1 year ago • 7 comments

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.

santiagorr avatar Jul 17 '24 21:07 santiagorr

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.

mtrmac avatar Jul 18 '24 18:07 mtrmac

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

nalind avatar Jul 18 '24 19:07 nalind

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.

santiagorr avatar Jul 19 '24 14:07 santiagorr

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

github-actions[bot] avatar Aug 19 '24 00:08 github-actions[bot]

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

rhatdan avatar Aug 19 '24 12:08 rhatdan

Either the latter, or tweak how push works.

nalind avatar Aug 21 '24 13:08 nalind

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

github-actions[bot] avatar Sep 21 '24 00:09 github-actions[bot]