On a Macbook M2 machine I am getting an error when creating a docker build.
This is the most boiled down example that can reproduce the error:
echo "FROM alpine:latest" | docker build --platform=linux/amd64 --progress=plain -f - .
error message
Notice the error in the last line:
#5 ERROR: no match for platform in manifest sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215: not found
------
> exporting to image:
------
ERROR: failed to solve: no match for platform in manifest sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215: not found
Full error output:
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 93B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/alpine:latest
#3 DONE 0.6s
#4 [1/1] FROM docker.io/library/alpine:latest@sha256:02bb6f428431fbc2809c5d1b41eab5a68350194fb508869a33cb1af4444c9b11
#4 resolve docker.io/library/alpine:latest@sha256:02bb6f428431fbc2809c5d1b41eab5a68350194fb508869a33cb1af4444c9b11 0.0s done
#4 CACHED
#5 exporting to image
#5 exporting layers done
#5 exporting manifest sha256:c887664786a565506760c1ebb17d0edbbc0f8427a4e723d05bba6dc1c199f63f done
#5 exporting config sha256:c9eabdf343eb2fef6b265aa86db47ee270dd0a170bf37bef1dcf94fa73236b65 done
#5 exporting attestation manifest sha256:ff813dfd9ec5f193d95d20bafa96b3d48b7510d178d4ef3195981314151856f1 done
#5 exporting manifest list sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215 done
#5 naming to moby-dangling@sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215 done
#5 unpacking to moby-dangling@sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215 done
#5 ERROR: no match for platform in manifest sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215: not found
------
> exporting to image:
------
ERROR: failed to solve: no match for platform in manifest sha256:d9ab3e9e8a65da61fb54c3e2471c8fabf787ce49403919bff7eaf10f99e33215: not found
However, I can run any of the images easily if I do either:
$ docker run --rm -ti --platform linux/amd64 alpine:latest uname -a
Linux b2a7299eadea 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 x86_64 Linux
$ docker run --rm -ti --platform linux/arm64 alpine:latest uname -a
Linux 00ecc31c7eeb 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 Linux
so there is a problem if I want to build an image, but no problem if I try to run it.
Troubleshooting:
- My machine is ARM-based apple M2 processor:
$ uname -a
Darwin 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:53:19 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6020 arm64
- I know that rosetta qemu emulation works, because I can run
$ docker run --rm -ti --platform linux/amd64 alpine:latest uname -m
x86_64
- docker builder is correctly configured for multiplatform builds:
$ docker builder ls
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
default * docker
default default running v0.11.6 linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64
desktop-linux docker
desktop-linux desktop-linux running v0.11.6 linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64
question:
so the question is: How can I use docker build
and actually save a docker image locally?