3

When I want to create multiarch builds with docker, I use the command:

docker buildx build --push --platform <list of archs> -t <tag1> -t <tag2> .

This works perfectly fine, but seems to be building the images concurrently. In most situations, it may be acceptable, but in some other cases, this seems to be too heavy, requires too much RAM and causes network failures (too many parallel connections).

Is there any way to build the images sequentially?

The only solution I found is to build for each arch separately and then use "docker manifest create" to assemble:

docker buildx build --push --platform <arch1> -t <tag-arch1> .
docker buildx build --push --platform <arch2> -t <tag-arch2> .
[...]
docker manifest create ... --amend ...
docker manifest push

This may be fine, but it seems that each image is supposed to be pushed to the registry for "docker manifest create" to be able to assemble. This is not very good, as it pollutes the list of images of tags I don't want.

Would it be possible to use "docker manifest create" on local images, without the need to upload each of them separately with a tag to the registry? Is there any better way to simply build the images sequentially? Thanks!

Luca Carlon
  • 9,546
  • 13
  • 59
  • 91

1 Answers1

2

At present, there's no way to limit the concurrency of a single build. This is currently an open issue with buildkit. There's also a similar issue to allow setting cgroup limits that would allow you to run the builds concurrently, but with less maximum CPU time, which would have a similar effect for some use cases.

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Thanks. What about building one platform ay a time and assembling, without necessarily pushing? – Luca Carlon Feb 21 '21 at 16:50
  • @LucaCarlon I haven't played a lot with manifest tool. The docs I saw didn't indicate a push was required, but it makes sense since the push is needed to calculate the digest of the manifest on the registry. I often see repos with platform specific tags, which are just an additional pointer to the same manifest, so no added disk space (maybe a few kb max for the pointer) is used for this. – BMitch Feb 21 '21 at 17:11