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

Unable to build docker image: invalid flag is passed to docker #17

Open
TudbuT opened this issue Oct 18, 2022 · 4 comments
Open

Unable to build docker image: invalid flag is passed to docker #17

TudbuT opened this issue Oct 18, 2022 · 4 comments
Labels
needs-information needs more information to replicate pending-close Issue will be closed if no further comments

Comments

@TudbuT
Copy link

TudbuT commented Oct 18, 2022

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

@Alexhuszagh
Copy link
Collaborator

Alexhuszagh commented Oct 18, 2022

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

@Alexhuszagh Alexhuszagh added needs-information needs more information to replicate pending-close Issue will be closed if no further comments labels Oct 18, 2022
@gongzhengyang
Copy link

gongzhengyang commented Jun 14, 2023

another solution is vim ~/.docker/config.json, add a line
{
"experimental": "enabled",
...
},
and run a command as docker buildx install

@TudbuT
Copy link
Author

TudbuT commented Jun 14, 2023

Oh, sorry. I forgot about this issue. Will provide log output shortly.

@BenjaminSchaaf
Copy link
Contributor

I had this same issue and solved it by installing docker from the official source. Ubuntu packages docker without BuildKit (buildx).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-information needs more information to replicate pending-close Issue will be closed if no further comments
Projects
None yet
Development

No branches or pull requests

4 participants