buildx
buildx copied to clipboard
Feature request: Save and reload multi-platform images
A common pattern I've used a lot is to have a two step build pipeline. The first step is to build the docker image and run tests etc. The second step is only run if some condition is true, and pushes the image to a registry.
When using buildx to build a multi-platform image, I can't seem to find a set of commands that allows me to do this. There are several output options that will save a multi-platform image to disk, either as a file tree, a tarball, or an OCI Image tarball. But I haven't been able to find a way to take that output and upload it to a registry in the next step.
Crucially, I don't want to run the build again, because that will happen in a different runner without any cache. Running the build again opens up the possibility that something changes, and then you push an untested image to the registry.
The way I do this with normal docker and single-platform images:
First step:
docker build . --tag "${IMAGE_NAME}:${TAG}" --tag "${IMAGE_NAME}:latest"- Run various tests
docker image save "${IMAGE_NAME}:${TAG}" "${IMAGE_NAME}:latest" | bzip2 > docker.tar.bz2- Save
docker.tar.bz2to suitable artifact storage
Second step:
- Fetch
docker.tar.bz2from artifact storage bunzip2 --stdout docker.tar.bz2 | docker image loaddocker push "${IMAGE_NAME}"
I have the same request, but for a slightly different reason: CI time & code reduction. I would like to avoid running the same build twice in CI, and it would be nice to define the build a single time and share it across multiple tagging & deployment jobs.
Hm. Does this issue cover the case where one wants to save out architecture specific images from the cache that buildx produced. I'd like to do docker save for each architecture specific image that buildx build --platform foo,bar produced.