[GH-ISSUE #192] Dockerfile: build failure on arm64 hosts #113

Closed
opened 2026-02-27 10:15:46 +03:00 by kerem · 5 comments
Owner

Originally created by @zenofile on GitHub (Dec 13, 2025).
Original GitHub issue: https://github.com/matze/wastebin/issues/192

The build fails on arm64 hosts because it uses a zig binary for the wrong architecture:

$ podman build --arch=arm64 --no-cache -t localhost/wastebin:latest -f Dockerfile 

[1/3] STEP 1/10: FROM rust:1.90 AS builder
[1/3] STEP 2/10: RUN rustup target add     aarch64-unknown-linux-musl     x86_64-unknown-linux-musl
info: downloading component 'rust-std' for 'aarch64-unknown-linux-musl'
info: installing component 'rust-std' for 'aarch64-unknown-linux-musl'
info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl'
info: installing component 'rust-std' for 'x86_64-unknown-linux-musl'
--> 41aece4b4d57
[1/3] STEP 3/10: RUN update-ca-certificates
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
--> d37aea127a64
[1/3] STEP 4/10: ENV ZIGVERSION=0.15.2
--> 5758315e67ca
[1/3] STEP 5/10: RUN wget https://ziglang.org/download/$ZIGVERSION/zig-x86_64-linux-$ZIGVERSION.tar.xz &&     tar -C /usr/local --strip-components=1 -xf zig-x86_64-linux-$ZIGVERSION.tar.xz &&     mv /usr/local/zig /usr/local/bin &&     rm zig-x86_64-linux-$ZIGVERSION.tar.xz
--2025-12-13 14:37:00--  https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz
Resolving ziglang.org (ziglang.org)... 2a01:4f9:3051:4bd2::2, 65.109.105.178
Connecting to ziglang.org (ziglang.org)|2a01:4f9:3051:4bd2::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53733924 (51M) [application/octet-stream]
Saving to: 'zig-x86_64-linux-0.15.2.tar.xz'

     0K .......... .......... .......... .......... ..........  0% 1.93M 27s
 52450K .......... .......... ....                            100%  348M=1.2s

2025-12-13 14:37:01 (43.5 MB/s) - 'zig-x86_64-linux-0.15.2.tar.xz' saved [53733924/53733924]

--> ecb51eaf1193
[1/3] STEP 6/10: RUN cargo install --locked cargo-zigbuild
    Updating crates.io index
 Downloading crates ...
  Downloaded cargo-zigbuild v0.20.1
  Installing cargo-zigbuild v0.20.1
    Updating crates.io index
    Updating crates.io index
 Downloading crates ...
  Downloaded anstyle-query v1.1.2
  Downloaded scroll_derive v0.12.0
  Downloaded option-ext v0.2.0
  Downloaded cargo-options v0.7.5
  Downloaded toml_datetime v0.6.8
  Downloaded anstyle v1.0.10
  Downloaded which v7.0.1
  Downloaded scroll v0.12.0
  Downloaded serde_spanned v0.6.8
  Downloaded utf8parse v0.2.2
  Downloaded env_home v0.1.0
  Downloaded semver v1.0.26
  Downloaded unicode-ident v1.0.16
  Downloaded serde_derive v1.0.219
  Downloaded serde v1.0.219
  Downloaded toml_edit v0.22.23
  Downloaded quote v1.0.38
  Downloaded winnow v0.7.1
  Downloaded serde_json v1.0.140
  Downloaded goblin v0.9.3
  Downloaded clap_builder v4.5.27
  Downloaded hashbrown v0.15.2
  Downloaded memchr v2.7.4
  Downloaded syn v2.0.98
  Downloaded indexmap v2.7.1
  Downloaded rustix v0.38.44
  Downloaded terminal_size v0.4.1
  Downloaded cargo-config2 v0.1.32
  Downloaded bitflags v2.8.0
  Downloaded ryu v1.0.19
  Downloaded clap v4.5.28
  Downloaded anyhow v1.0.98
  Downloaded proc-macro2 v1.0.93
  Downloaded log v0.4.25
  Downloaded clap_derive v4.5.28
  Downloaded cargo_metadata v0.19.0
  Downloaded thiserror-impl v1.0.69
  Downloaded thiserror v1.0.69
  Downloaded target-lexicon v0.13.1
  Downloaded strsim v0.11.1
  Downloaded path-slash v0.2.1
  Downloaded fat-macho v0.4.9
  Downloaded crc-catalog v2.4.0
  Downloaded crc v3.2.1
  Downloaded cargo-platform v0.1.6
  Downloaded camino v1.1.9
  Downloaded anstyle-parse v0.2.6
  Downloaded anstream v0.6.18
  Downloaded rustc_version v0.4.1
  Downloaded plain v0.2.3
  Downloaded is_terminal_polyfill v1.70.1
  Downloaded libc v0.2.169
  Downloaded either v1.13.0
  Downloaded itoa v1.0.14
  Downloaded fs-err v3.1.0
  Downloaded errno v0.3.10
  Downloaded colorchoice v1.0.3
  Downloaded clap_lex v0.7.4
  Downloaded rustflags v0.1.6
  Downloaded dirs v5.0.1
  Downloaded shlex v1.3.0
  Downloaded heck v0.5.0
  Downloaded equivalent v1.0.1
  Downloaded dirs-sys v0.4.1
  Downloaded autocfg v1.4.0
  Downloaded linux-raw-sys v0.4.15
   Compiling proc-macro2 v1.0.93
   Compiling unicode-ident v1.0.16
   Compiling serde v1.0.219
   Compiling rustix v0.38.44
   Compiling bitflags v2.8.0
   Compiling linux-raw-sys v0.4.15
   Compiling utf8parse v0.2.2
   Compiling anstyle-parse v0.2.6
   Compiling anstyle-query v1.1.2
   Compiling semver v1.0.26
   Compiling libc v0.2.169
   Compiling quote v1.0.38
   Compiling syn v2.0.98
   Compiling colorchoice v1.0.3
   Compiling is_terminal_polyfill v1.70.1
   Compiling anstyle v1.0.10
   Compiling hashbrown v0.15.2
   Compiling anstream v0.6.18
   Compiling equivalent v1.0.1
   Compiling camino v1.1.9
   Compiling clap_lex v0.7.4
   Compiling autocfg v1.4.0
   Compiling thiserror v1.0.69
   Compiling serde_json v1.0.140
   Compiling heck v0.5.0
   Compiling strsim v0.11.1
   Compiling fs-err v3.1.0
   Compiling indexmap v2.7.1
   Compiling terminal_size v0.4.1
   Compiling clap_builder v4.5.27
   Compiling target-lexicon v0.13.1
   Compiling plain v0.2.3
   Compiling ryu v1.0.19
   Compiling serde_derive v1.0.219
   Compiling scroll_derive v0.12.0
   Compiling clap_derive v4.5.28
   Compiling scroll v0.12.0
   Compiling thiserror-impl v1.0.69
   Compiling log v0.4.25
   Compiling winnow v0.7.1
   Compiling itoa v1.0.14
   Compiling memchr v2.7.4
   Compiling option-ext v0.2.0
   Compiling anyhow v1.0.98
   Compiling dirs-sys v0.4.1
   Compiling goblin v0.9.3
   Compiling clap v4.5.28
   Compiling either v1.13.0
   Compiling env_home v0.1.0
   Compiling crc-catalog v2.4.0
   Compiling crc v3.2.1
   Compiling which v7.0.1
   Compiling toml_datetime v0.6.8
   Compiling serde_spanned v0.6.8
   Compiling toml_edit v0.22.23
   Compiling cargo-platform v0.1.6
   Compiling cargo_metadata v0.19.0
   Compiling cargo-config2 v0.1.32
   Compiling fat-macho v0.4.9
   Compiling rustc_version v0.4.1
   Compiling cargo-options v0.7.5
   Compiling dirs v5.0.1
   Compiling path-slash v0.2.1
   Compiling shlex v1.3.0
   Compiling rustflags v0.1.6
   Compiling cargo-zigbuild v0.20.1
    Finished `release` profile [optimized] target(s) in 42.21s
  Installing /usr/local/cargo/bin/cargo-zigbuild
   Installed package `cargo-zigbuild v0.20.1` (executable `cargo-zigbuild`)
--> f5596bc4a4b7
[1/3] STEP 7/10: WORKDIR /app
--> c42286e02d43
[1/3] STEP 8/10: COPY . .
--> 3ee1310f799b
[1/3] STEP 9/10: RUN cargo zigbuild     --release     --target aarch64-unknown-linux-musl     --target x86_64-unknown-linux-musl     --bin wastebin     --bin wastebin-ctl
Error: Failed to find zig

Caused by:
    Exec format error (os error 8)
Error: building at STEP "RUN cargo zigbuild     --release     --target aarch64-unknown-linux-musl     --target x86_64-unknown-linux-musl     --bin wastebin     --bin wastebin-ctl": while running runtime: exit status 1
Originally created by @zenofile on GitHub (Dec 13, 2025). Original GitHub issue: https://github.com/matze/wastebin/issues/192 The build fails on arm64 hosts because it uses a zig binary for the wrong architecture: ```log $ podman build --arch=arm64 --no-cache -t localhost/wastebin:latest -f Dockerfile [1/3] STEP 1/10: FROM rust:1.90 AS builder [1/3] STEP 2/10: RUN rustup target add aarch64-unknown-linux-musl x86_64-unknown-linux-musl info: downloading component 'rust-std' for 'aarch64-unknown-linux-musl' info: installing component 'rust-std' for 'aarch64-unknown-linux-musl' info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl' info: installing component 'rust-std' for 'x86_64-unknown-linux-musl' --> 41aece4b4d57 [1/3] STEP 3/10: RUN update-ca-certificates Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. --> d37aea127a64 [1/3] STEP 4/10: ENV ZIGVERSION=0.15.2 --> 5758315e67ca [1/3] STEP 5/10: RUN wget https://ziglang.org/download/$ZIGVERSION/zig-x86_64-linux-$ZIGVERSION.tar.xz && tar -C /usr/local --strip-components=1 -xf zig-x86_64-linux-$ZIGVERSION.tar.xz && mv /usr/local/zig /usr/local/bin && rm zig-x86_64-linux-$ZIGVERSION.tar.xz --2025-12-13 14:37:00-- https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz Resolving ziglang.org (ziglang.org)... 2a01:4f9:3051:4bd2::2, 65.109.105.178 Connecting to ziglang.org (ziglang.org)|2a01:4f9:3051:4bd2::2|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 53733924 (51M) [application/octet-stream] Saving to: 'zig-x86_64-linux-0.15.2.tar.xz' 0K .......... .......... .......... .......... .......... 0% 1.93M 27s 52450K .......... .......... .... 100% 348M=1.2s 2025-12-13 14:37:01 (43.5 MB/s) - 'zig-x86_64-linux-0.15.2.tar.xz' saved [53733924/53733924] --> ecb51eaf1193 [1/3] STEP 6/10: RUN cargo install --locked cargo-zigbuild Updating crates.io index Downloading crates ... Downloaded cargo-zigbuild v0.20.1 Installing cargo-zigbuild v0.20.1 Updating crates.io index Updating crates.io index Downloading crates ... Downloaded anstyle-query v1.1.2 Downloaded scroll_derive v0.12.0 Downloaded option-ext v0.2.0 Downloaded cargo-options v0.7.5 Downloaded toml_datetime v0.6.8 Downloaded anstyle v1.0.10 Downloaded which v7.0.1 Downloaded scroll v0.12.0 Downloaded serde_spanned v0.6.8 Downloaded utf8parse v0.2.2 Downloaded env_home v0.1.0 Downloaded semver v1.0.26 Downloaded unicode-ident v1.0.16 Downloaded serde_derive v1.0.219 Downloaded serde v1.0.219 Downloaded toml_edit v0.22.23 Downloaded quote v1.0.38 Downloaded winnow v0.7.1 Downloaded serde_json v1.0.140 Downloaded goblin v0.9.3 Downloaded clap_builder v4.5.27 Downloaded hashbrown v0.15.2 Downloaded memchr v2.7.4 Downloaded syn v2.0.98 Downloaded indexmap v2.7.1 Downloaded rustix v0.38.44 Downloaded terminal_size v0.4.1 Downloaded cargo-config2 v0.1.32 Downloaded bitflags v2.8.0 Downloaded ryu v1.0.19 Downloaded clap v4.5.28 Downloaded anyhow v1.0.98 Downloaded proc-macro2 v1.0.93 Downloaded log v0.4.25 Downloaded clap_derive v4.5.28 Downloaded cargo_metadata v0.19.0 Downloaded thiserror-impl v1.0.69 Downloaded thiserror v1.0.69 Downloaded target-lexicon v0.13.1 Downloaded strsim v0.11.1 Downloaded path-slash v0.2.1 Downloaded fat-macho v0.4.9 Downloaded crc-catalog v2.4.0 Downloaded crc v3.2.1 Downloaded cargo-platform v0.1.6 Downloaded camino v1.1.9 Downloaded anstyle-parse v0.2.6 Downloaded anstream v0.6.18 Downloaded rustc_version v0.4.1 Downloaded plain v0.2.3 Downloaded is_terminal_polyfill v1.70.1 Downloaded libc v0.2.169 Downloaded either v1.13.0 Downloaded itoa v1.0.14 Downloaded fs-err v3.1.0 Downloaded errno v0.3.10 Downloaded colorchoice v1.0.3 Downloaded clap_lex v0.7.4 Downloaded rustflags v0.1.6 Downloaded dirs v5.0.1 Downloaded shlex v1.3.0 Downloaded heck v0.5.0 Downloaded equivalent v1.0.1 Downloaded dirs-sys v0.4.1 Downloaded autocfg v1.4.0 Downloaded linux-raw-sys v0.4.15 Compiling proc-macro2 v1.0.93 Compiling unicode-ident v1.0.16 Compiling serde v1.0.219 Compiling rustix v0.38.44 Compiling bitflags v2.8.0 Compiling linux-raw-sys v0.4.15 Compiling utf8parse v0.2.2 Compiling anstyle-parse v0.2.6 Compiling anstyle-query v1.1.2 Compiling semver v1.0.26 Compiling libc v0.2.169 Compiling quote v1.0.38 Compiling syn v2.0.98 Compiling colorchoice v1.0.3 Compiling is_terminal_polyfill v1.70.1 Compiling anstyle v1.0.10 Compiling hashbrown v0.15.2 Compiling anstream v0.6.18 Compiling equivalent v1.0.1 Compiling camino v1.1.9 Compiling clap_lex v0.7.4 Compiling autocfg v1.4.0 Compiling thiserror v1.0.69 Compiling serde_json v1.0.140 Compiling heck v0.5.0 Compiling strsim v0.11.1 Compiling fs-err v3.1.0 Compiling indexmap v2.7.1 Compiling terminal_size v0.4.1 Compiling clap_builder v4.5.27 Compiling target-lexicon v0.13.1 Compiling plain v0.2.3 Compiling ryu v1.0.19 Compiling serde_derive v1.0.219 Compiling scroll_derive v0.12.0 Compiling clap_derive v4.5.28 Compiling scroll v0.12.0 Compiling thiserror-impl v1.0.69 Compiling log v0.4.25 Compiling winnow v0.7.1 Compiling itoa v1.0.14 Compiling memchr v2.7.4 Compiling option-ext v0.2.0 Compiling anyhow v1.0.98 Compiling dirs-sys v0.4.1 Compiling goblin v0.9.3 Compiling clap v4.5.28 Compiling either v1.13.0 Compiling env_home v0.1.0 Compiling crc-catalog v2.4.0 Compiling crc v3.2.1 Compiling which v7.0.1 Compiling toml_datetime v0.6.8 Compiling serde_spanned v0.6.8 Compiling toml_edit v0.22.23 Compiling cargo-platform v0.1.6 Compiling cargo_metadata v0.19.0 Compiling cargo-config2 v0.1.32 Compiling fat-macho v0.4.9 Compiling rustc_version v0.4.1 Compiling cargo-options v0.7.5 Compiling dirs v5.0.1 Compiling path-slash v0.2.1 Compiling shlex v1.3.0 Compiling rustflags v0.1.6 Compiling cargo-zigbuild v0.20.1 Finished `release` profile [optimized] target(s) in 42.21s Installing /usr/local/cargo/bin/cargo-zigbuild Installed package `cargo-zigbuild v0.20.1` (executable `cargo-zigbuild`) --> f5596bc4a4b7 [1/3] STEP 7/10: WORKDIR /app --> c42286e02d43 [1/3] STEP 8/10: COPY . . --> 3ee1310f799b [1/3] STEP 9/10: RUN cargo zigbuild --release --target aarch64-unknown-linux-musl --target x86_64-unknown-linux-musl --bin wastebin --bin wastebin-ctl Error: Failed to find zig Caused by: Exec format error (os error 8) Error: building at STEP "RUN cargo zigbuild --release --target aarch64-unknown-linux-musl --target x86_64-unknown-linux-musl --bin wastebin --bin wastebin-ctl": while running runtime: exit status 1 ```
kerem closed this issue 2026-02-27 10:15:47 +03:00
Author
Owner

@matze commented on GitHub (Dec 13, 2025):

Which is to be expected because the dockerfile is supposed to be used for x86_64 hosts only. I don't have an aarch64 host which is why I will use it that way to build future images.

Can I close this issue? It should I add some clarification into the dockerfile and/or readme?

<!-- gh-comment-id:3649571879 --> @matze commented on GitHub (Dec 13, 2025): Which is to be expected because the dockerfile is supposed to be used for x86_64 hosts only. I don't have an aarch64 host which is why I will use it that way to build future images. Can I close this issue? It should I add some clarification into the dockerfile and/or readme?
Author
Owner

@zenofile commented on GitHub (Dec 13, 2025):

That is unfortunate. You can close the issue.

<!-- gh-comment-id:3649574579 --> @zenofile commented on GitHub (Dec 13, 2025): That is unfortunate. You can close the issue.
Author
Owner

@matze commented on GitHub (Dec 13, 2025):

I use Docker not podman but what exactly is the issue of building an aarch64 image on an x86_64 host with the --target arm64 or --target x86_64 option?

<!-- gh-comment-id:3649715786 --> @matze commented on GitHub (Dec 13, 2025): I use Docker not podman but what exactly is the issue of building an aarch64 image on an x86_64 host with the `--target arm64` or `--target x86_64` option?
Author
Owner

@zenofile commented on GitHub (Dec 13, 2025):

Just an inconvenience, not a real issue. Since you removed Dockerfile.arm, I mistakenly assumed the main Dockerfile should also work on aarch64 hosts, but you made it clear now that this wasn't the intention.

<!-- gh-comment-id:3649735514 --> @zenofile commented on GitHub (Dec 13, 2025): Just an inconvenience, not a real issue. Since you removed `Dockerfile.arm`, I mistakenly assumed the main Dockerfile should also work on aarch64 hosts, but you made it clear now that this wasn't the intention.
Author
Owner

@matze commented on GitHub (Dec 13, 2025):

I think for "real" (whatever that means) portable Dockerfile's we could eschew of the --target flag during the cargo build. But that would mean for me to build with QEMU which is unbearably slow.

<!-- gh-comment-id:3649753657 --> @matze commented on GitHub (Dec 13, 2025): I think for "real" (whatever that means) portable Dockerfile's we could eschew of the `--target` flag during the `cargo` build. But that would mean for me to build with QEMU which is unbearably slow.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/wastebin-matze#113
No description provided.