fresh-mechanic-68429
03/25/2024, 9:18 PMbroad-processor-92400
03/25/2024, 9:28 PMfresh-mechanic-68429
03/25/2024, 9:31 PMdocker buildx build ... --push
https://docs.docker.com/build/building/multi-platform/fresh-mechanic-68429
03/25/2024, 9:32 PMbroad-processor-92400
03/25/2024, 9:54 PMdocker_image(..., build_platform=["linux/amd64", "linux/arm64"]) ?fresh-mechanic-68429
03/26/2024, 2:25 AMdocker_image(
build_platform = [
"linux/amd64",
"linux/arm64",
]
)
produces ERROR: docker exporter does not currently support exporting manifest lists
We can force it to use a different container builder using the env var BUILDX_BUILDER in the pants toml.
First create the builder outside of pants
docker buildx create --name builder --driver docker-container --use --bootstrap
Then set the env var in the pants toml
[docker]
use_buildx = true
env_vars = [
"BUILDX_BUILDER=builder",
...
]
This will actually produce the same error as before, despite making progress
ERROR: docker exporter does not currently support exporting manifest lists
We can switch the output to type=image which allows pants package to execute successfully
docker_image(
build_platform = [
"linux/amd64",
"linux/arm64",
],
output={
'type': 'image',
},
)
But this is somewhat limited because we can’t actually push the image to a registry or consume it in another target.
Trying to push the image to a registry will produce the following error
tag does not exist: <tag>
In this setup, where I want buildx to push a multi-arch manifest, the build and push commands cannot be separated. So in pants lingo, the package and publish rule need to essentially be the same, except publish also adds an additional cli flag --pushfresh-mechanic-68429
03/26/2024, 2:46 AMoutput={
'type': 'image,push=true',
}
which will successfully push to the registry, but it does so when running pants package which breaks the semantic meaning.fresh-mechanic-68429
03/26/2024, 2:47 AMbroad-processor-92400
03/26/2024, 2:57 AMfresh-mechanic-68429
03/26/2024, 3:00 AMbroad-processor-92400
03/26/2024, 3:04 AMfresh-mechanic-68429
03/26/2024, 3:18 AMpackage can be used with no modifications, in this case thats not true though. buildx has no separate “push” command like docker push, I need to re-invoke docker buildx build but with slightly different cli arguments.
One way that could work is if I add and inspect the necessary fields on the publish request, then manually construct the DockerPackageFieldSet, and change the output typebroad-processor-92400
03/26/2024, 3:28 AMfresh-mechanic-68429
03/26/2024, 3:31 AMfresh-mechanic-68429
03/26/2024, 3:47 AM