Feature: add the --builder flag support for build parameter for multi-arch builds
Description
- Brief: Reference to the documentation Since it's possible to support multi-arch builds in docker-compose.yml,
Additionally reference to the documentation
In newer versions of Docker Desktop and Docker Engine, you’re using Buildx by default when you invoke the docker build command.
as a result, if the buildkit is enabled on the docker engine, then I assume docker compose build would use buildx
So during building simultaneous services with multi-arch there is a buildkit issue | buildx issue faced while trying to build multi arch builds for multiple services
Note: I'm not sure whether this is buildx issue or buildkit issue, so I created an issue for both
so in order to get over this issue it would be so beneficial for multi-arch builds if the builder could be either passed via a flag or defined in the docker-compose.yml for e.g docker-compose.yml
Multiple services:
version: '3.7'
services:
service_1:
container_name: service_1-${VERSION}
image: service_1:${VERSION}
build:
context: .
dockerfile: Dockerfile
builder: test1
platforms:
- ${PLATFORM_1}
- ${PLATFORM_2}
service_2:
container_name: service_2-${VERSION}
image: service_2:${VERSION}
build:
context: .
dockerfile: Dockerfile
builder: test2
platforms:
- ${PLATFORM_1}
- ${PLATFORM_2}
service_3:
container_name: service_3-${VERSION}
image: service_3:${VERSION}
build:
context: .
dockerfile: Dockerfile
builder: test3
platforms:
- ${PLATFORM_1}
- ${PLATFORM_2}
commands to run
docker buildx create --name test1
docker buildx create --name test2
docker buildx create --name test3
docker compose build service_1 service_2 service_3
Or for a single service
version: '3.7'
services:
service_1:
container_name: service_1-${VERSION}
image: service_1:${VERSION}
build:
context: .
dockerfile: Dockerfile
platforms:
- ${PLATFORM_1}
- ${PLATFORM_2}
docker buildx create --name test1
docker compose build --builder test1 service_1
We could indeed introduce builder, as a follow-up for https://github.com/compose-spec/compose-spec/issues/233
Compose v2.20.0+ respects the BUILDX_BUILDER env var and also supports build --builder=my-builder.
Note that other commands that (might) perform builds like up and run do not support the --builder flag currently.