Buildx --push overwrites any previous architectures

Hi,

I am trying to batch my buildx calls into separate CLI invocations, in order to play nice with limited RAM. However, each time I invoke docker buildx build --push…, only the last command’s architectures show up in Docker Hub. All the previous 8 architectures are erased :frowning:

As a workaround, I am performing my --push’es as a distinct docker buildx build --platforms… after my buildx cache is tested and ready. For better or worse, buildx’s caching behavior does not apply the same overwrite logic that buildx’s pushing does.

Unfortunately, that triggers some really spurious warnings about lack of --load / --push… Well, neither of those options are particularly suited to the intuitive, batched, as-many-platforms-as-possible workflow.

Spurious warning:

WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load

This warning isn’t always actionable. -q fails to silence it. It’s thrown together with critical build information in a catch-all stderr stream. A bit distracting.

Setting environment variable BUILDX_NO_DEFAULT_LOAD to “true” appears to finally quash this warning. Although it’s completely missing from the official buildx documentation.

Back to --push overwrites. Projects stand to benefit from a non-architecture erasing --push behavior. For example, when one FROM base image offers one set of architectures, and another base image offers another mutually set of architectures. The developer can support the union of these architectures, by pushing half of them derived from one base image, and the other half derived from another base image. But that option is not available as long as --push continues to erase any previously uploaded architectures. As a workaround, the developer would have to use different image names / tags. Which breaks the uniformity of the images that buildx was meant to provide.

1 Like

I’m having the same problem I think. My GitHub workflow is configured to push to linux/amd64 and linux/arm64. The amd64 images is successfully pushed. When the arm64 build completes successfully, the amd64 image doesn’t exist anymore (looking at my repo tags on Docker Hub).

The workflow I’m using is at netpanzer/.github/workflows/docker.yml at 6eddae218646c411b35fcc432fef1c2601f6572b · netpanzer/netpanzer · GitHub

This happened to me last week when I tried with a similar configuration.

I thought it might be happening because I have the platforms in a matrix (which I saw in the docs was ok) instead of putting them on one line, i.e. platforms: linux/amd64, linux/arm64. Anyone have the same issue?

I wrote a script to interact safely with buildx.

https://github.com/mcandre/tug

1 Like

I got this working for now. Some details in this discussion I started on the build-push-action repo. I still don’t know why what I was doing wasn’t working as expected, as the matrix usage was in the Docker docs (as mentioned in the discussion).

I’ve encountered this problem again on another repo, while attempting again to use a matrix. I opened a ticket.

@mcandre Thanks! I briefly looked over tug and gave it a star. I’ll keep it in mind in case I or someone I know run into future problems. :wink: