cross-toolchains
cross-toolchains copied to clipboard
Unable to build docker image: invalid flag is passed to docker
Shell output:
$ sudo cargo build-docker-image x86_64-pc-windows-msvc-cross --tag local
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/xtask build-docker-image x86_64-pc-windows-msvc-cross --tag local`
[cross] note: Build x86_64-pc-windows-msvc-cross for x86_64-unknown-linux-gnu
unknown flag: --platform
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
[Docker help page follows]
Docker version (most recent stable at the time of making this issue):
Client:
Version: 20.10.19
API version: 1.41
Go version: go1.19.2
Git commit: d85ef84533
Built: Sat Oct 15 20:20:02 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Rust version (most recent stable at the time of making this issue):
stable-x86_64-unknown-linux-gnu (default) @ rustc 1.64.0 (a55dd71d5 2022-09-19)
Error:
0: docker buildx build --platform linux/amd64 --build-arg 'CROSS_TARGET_TRIPLE=X86_64_PC_WINDOWS_MSVC_CROSS' --load --pull --cache-from 'type=registry,ref=ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:main' --tag ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local --label 'org.cross-rs.for-cross-target=x86_64-pc-windows-msvc-cross' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' -f /run/media/tudbut/a5187034-7bde-48cd-b51f-9957d531c89a/cross/docker/cross-toolchains/docker/Dockerfile.x86_64-pc-windows-msvc-cross --progress auto .
failed with exit status: 125
Can you check the output of docker buildx
? With container engines, the flags have higher priority than the subcommands, so something like docker x --platform
will produce an error unknown flag: --platform
when the subcommand x
doesn't exist. In this case, if BuildKit isn't present and therefore no buildx
, the error with the platform flag is the first to show up.
If BuildKit is not available, we provide an environment variable CROSS_CONTAINER_ENGINE_NO_BUILDKIT to avoid using buildx build
, only build
, when building Docker images. In this case:
$ CROSS_CONTAINER_ENGINE_NO_BUILDKIT=1 sudo cargo build-docker-image x86_64-pc-windows-msvc-cross --tag local
another solution is vim ~/.docker/config.json, add a line
{
"experimental": "enabled",
...
},
and run a command as docker buildx install
Oh, sorry. I forgot about this issue. Will provide log output shortly.
I had this same issue and solved it by installing docker from the official source. Ubuntu packages docker without BuildKit (buildx).