quarkusio/quarkus · error · RuntimeException

The native binary produced by the build is not a Linux binar

Error message

The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. Consider adding "quarkus.native.container-build=true" to your configuration.

What it means

A container image for Linux needs a Linux executable. After a native build, Quarkus checks whether the produced native binary is a Linux binary; if it was compiled for the host OS (e.g. macOS or Windows) it cannot be placed in a Linux container, so the build throws this RuntimeException.

Source

Thrown at extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java:223

            OutputTargetBuildItem out,
            BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
            BuildProducer<ContainerImageBuilderBuildItem> containerImageBuilder,
            PackageConfig packageConfig,
            NativeImageBuildItem nativeImage,
            ContainerRuntime... containerRuntimes) {

        var buildContainerImage = buildContainerImageNeeded(containerImageConfig, buildRequest);
        var pushContainerImage = pushContainerImageNeeded(containerImageConfig, pushRequest);

        if (buildContainerImage || pushContainerImage) {
            if (!containerRuntimeStatusBuildItem.isContainerRuntimeAvailable()) {
                throw new RuntimeException(
                        "Unable to build container image. Please check your %s installation."
                                .formatted(getProcessorImplementation()));
            }

            if (!NativeBinaryUtil.nativeIsLinuxBinary(nativeImage)) {
                throw new RuntimeException(
                        "The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. Consider adding \"quarkus.native.container-build=true\" to your configuration.");
            }

            if (buildContainerImage) {
                LOGGER.infof("Starting (local) container image build for native binary using %s",
                        getProcessorImplementation());
            }

            var executableName = getExecutableName(config, containerRuntimes);
            var dockerfilePaths = getDockerfilePaths(config, true, packageConfig, out);
            var builtContainerImage = createContainerImage(containerImageConfig, config, containerImage, out, dockerfilePaths,
                    buildContainerImage, pushContainerImage, packageConfig, executableName);

            // a pull is not required when using this image locally because the strategy always builds the container image
            // locally before pushing it to the registry
            artifactResultProducer.produce(
                    new ArtifactResultBuildItem(
                            null,

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add -Dquarkus.native.container-build=true to the native build so GraalVM runs inside a Linux container and produces a Linux binary
  2. Or build natively inside a Linux environment/CI runner
  3. Set quarkus.native.container-build=true in application.properties for local native builds
  4. Rebuild the native image after enabling the flag; the check re-runs on the new binary

Example fix

# before
./mvnw package -Dnative -Dquarkus.container-image.build=true
# after
./mvnw package -Dnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true
Defensive patterns

Strategy: validation

Validate before calling

String fileOut = new String(ProcessHelpers.exec("file", "target/quarkus-app/...-runner").readAllBytes());
if (!fileOut.contains("ELF")) {
    throw new IllegalStateException("Native binary is not Linux; rebuild with -Dquarkus.native.container-build=true");
}

Type guard

boolean isLinuxNativeBinary(Path runner, ProcessExecutor exec) throws Exception {
    String out = exec.run("file", runner.toString());
    return out.contains("ELF") && out.contains("x86-64") || out.contains("ELF") && out.contains("aarch64");
}

Try / catch

try {
    jibOrDockerNativeBuild();
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("not a Linux binary")) {
        throw new IllegalStateException("Rebuild natively with quarkus.native.container-build=true", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Running a native build locally on macOS/Windows without quarkus.native.container-build=true, then building a container image from the resulting native binary.

Common situations: Developer builds natively on a Mac (produces a Mach-O binary) then tries docker build; forgetting container-build on Windows; CI agents where the native step ran without container-build and produced a non-Linux binary.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/8f4e6b7d2b08fe4f. Report an issue: GitHub.