Open ciaranmcnulty opened 2 years ago
We should probably show a warning for this case
It doesn't seem like this works with docker-image sources either.
docker buildx build --no-cache --platform=linux/arm64 --build-context=busybox:latest=docker-image://busybox:latest - <<EOF
FROM --platform=\${BUILDPLATFORM} busybox:latest
RUN echo hello > /foo
EOF
[+] Building 2.3s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 107B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [context busybox] load metadata for busybox:latest 1.6s
=> [auth] library/busybox:pull token for registry-1.docker.io 0.0s
=> [context busybox] busybox:latest 0.4s
=> => resolve docker.io/library/busybox:latest 0.1s
=> => sha256:87379020f3b6731a4b64976e614d305f5c121d153c049d14ba600ff24bbac012 828.68kB / 828.68kB 0.2s
=> => extracting sha256:87379020f3b6731a4b64976e614d305f5c121d153c049d14ba600ff24bbac012 0.1s
=> ERROR [1/2] RUN echo hello > /foo 0.2s
------
> [1/2] RUN echo hello > /foo:
#0 0.119 standard_init_linux.go:228: exec user process caused: exec format error
------
Dockerfile:2
--------------------
1 | FROM --platform=${BUILDPLATFORM} busybox:latest
2 | >>> RUN echo hello > /foo
3 |
--------------------
error: failed to solve: process "/bin/sh -c echo hello > /foo" did not complete successfully: exit code: 1[+] Building 2.3s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 107B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [context busybox] load metadata for busybox:latest 1.6s
=> [auth] library/busybox:pull token for registry-1.docker.io 0.0s
=> [context busybox] busybox:latest 0.4s
=> => resolve docker.io/library/busybox:latest 0.1s
=> => sha256:87379020f3b6731a4b64976e614d305f5c121d153c049d14ba600ff24bbac012 828.68kB / 828.68kB 0.2s
=> => extracting sha256:87379020f3b6731a4b64976e614d305f5c121d153c049d14ba600ff24bbac012 0.1s
=> ERROR [1/2] RUN echo hello > /foo 0.2s
------
> [1/2] RUN echo hello > /foo:
#0 0.119 standard_init_linux.go:228: exec user process caused: exec format error
------
Dockerfile:2
--------------------
1 | FROM --platform=${BUILDPLATFORM} busybox:latest
2 | >>> RUN echo hello > /foo
3 |
--------------------
error: failed to solve: process "/bin/sh -c echo hello > /foo" did not complete successfully: exit code: 1
The failure of course requires that you don't have binfmt or something else loaded.
This happened to me again today, and I went and asked on the Slack about it 🤦
A warning or fail at runtime would be useful "Can not override platform for target foo
, using linux/arm64" or something
I naively tried something like this in my project:
My expectation was that the
expensive
stage would only run once on my native platform. However, I see it running twice in parallelThis however only runs the expensive stage once:
My guess is that
--platform
only applies to docker image sources? Should it be an error if used with something else?