Docker/Compose/EnvVar/COMPOSE_BAKE/Concept/When to use vs buildx
Properties
COMPOSE_BAKE=true vs explicit Buildx/Bake
Overview
Context
Key Principles
Mechanism
- With the variable set, Compose converts each service’s build section into a Bake target and runs
docker buildx bake. - Bake inherits BuildKit: parallel DAGs, cross-arch, secrets, and cache import/export.
- Without the flag, Compose loops over services sequentially, missing cross-service cache and multi-arch output.
- With the variable set, Compose converts each service’s build section into a Bake target and runs
When to Use
Examples
- bash
# Local workstation COMPOSE_BAKE=true docker compose build # GitHub Actions snippet pushing to ECR - uses: aws-actions/configure-aws-credentials@v4 - uses: aws-actions/amazon-ecr-login@v2 - uses: docker/setup-buildx-action@v3 - uses: docker/build-push-action@v6 with: file: Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.login-ecr.outputs.registry }}/my-app:latest cache-from: type=gha cache-to: type=gha,mode=max
Misconceptions
Related