Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly broken interaction between --platform and --build-context #2939

Open
3 tasks done
PigeonF opened this issue Jan 22, 2025 · 0 comments
Open
3 tasks done

Possibly broken interaction between --platform and --build-context #2939

PigeonF opened this issue Jan 22, 2025 · 0 comments

Comments

@PigeonF
Copy link

PigeonF commented Jan 22, 2025

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I am trying to build a multiplatform image (linux + windows). The image build succeeds, but when I try to pin base images using --build-context, the build fails because buildx seemingly (?) attempts to load the specified build context for all platforms, instead of only for the platforms that are actually required.

Expected behaviour

When specifying a context with --build-context, the context should only be loaded for platforms that are actually used, not all platforms specified on the commandline.

Actual behaviour

The build fails because buildx attempts to load the --build-context for a platform that it does not have a manifest for (in my specific example, it attempts to load alpine:3 for windows/amd64).

Buildx version

github.com/docker/buildx v0.18.0

Docker info

Client:
 Version:    27.3.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.18.0
    Path:     /nix/store/l33y17iwhlzp5q3fxkz355ga8s5a93ni-docker-plugins/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.30.3
    Path:     /nix/store/l33y17iwhlzp5q3fxkz355ga8s5a93ni-docker-plugins/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 33
 Server Version: 27.5.0
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: journald
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: refs/tags/v2.0.2
 runc version: 
 init version: 
 Security Options:
  seccomp
   Profile: /nix/store/raihl25n2fd8f1f7kz008azbdls8l8ji-seccomp.json
  cgroupns
 Kernel Version: 6.6.68
 Operating System: NixOS 25.05 (Warbler)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 23.37GiB
 Name: geonosis
 ID: 1bde965b-61b0-4cbd-94e0-91a66e0c1109
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: pigeonf
 Experimental: false
 Insecure Registries:
  cache.internal
  registry.internal
  registry.internal:80
  127.0.0.0/8
 Registry Mirrors:
  http://cache.internal/
 Live Restore Enabled: true

WARNING: daemon is not using the default seccomp profile

Builders list

NAME/NODE              DRIVER/ENDPOINT                    STATUS    BUILDKIT   PLATFORMS
gallant_hopper*        docker-container                                        
 \_ gallant_hopper0     \_ unix:///var/run/docker.sock    running   v0.18.2    linux/amd64 (+3), linux/386
default                docker                                                  
 \_ default             \_ default                        running   v0.17.3    linux/amd64 (+3)

Configuration

FROM docker.io/library/alpine:3 AS container-linux
FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 AS container-windows

FROM container-${TARGETOS}

The following works as expected

docker buildx build . --platform "linux/amd64,windows/amd64"

Combining --platform with --build-context fails

$ docker buildx build . --platform "linux/amd64,windows/amd64" --build-context "docker.io/library/alpine:3=docker-image://docker.io/library/alpine:3"  --progress=plain
#0 building with "gallant_hopper" instance using docker-container driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 190B done
#1 DONE 0.0s

#2 [windows/amd64 internal] load metadata for mcr.microsoft.com/windows/nanoserver:ltsc2025
#2 DONE 0.1s

#3 [context alpine:3] load metadata for docker.io/library/alpine:3
#3 ERROR: no match for platform in manifest: not found

#4 [context alpine:3] load metadata for docker.io/library/alpine:3
#4 DONE 0.5s
------
 > [context alpine:3] load metadata for docker.io/library/alpine:3:
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:1
--------------------
   1 | >>> FROM docker.io/library/alpine:3 AS container-linux
   2 |     FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 AS container-windows
   3 |     
--------------------
ERROR: failed to solve: failed to resolve source metadata for docker.io/library/alpine:3: no match for platform in manifest: not found

Build logs


Additional info

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants