{"record":{"id":"8f4e6b7d2b08fe4f","repo":"quarkusio/quarkus","slug":"the-native-binary-produced-by-the-build-is-not-a-l-8f4e6b","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java","lineNumber":223,"sourceCode":"            OutputTargetBuildItem out,\n            BuildProducer<ArtifactResultBuildItem> artifactResultProducer,\n            BuildProducer<ContainerImageBuilderBuildItem> containerImageBuilder,\n            PackageConfig packageConfig,\n            NativeImageBuildItem nativeImage,\n            ContainerRuntime... containerRuntimes) {\n\n        var buildContainerImage = buildContainerImageNeeded(containerImageConfig, buildRequest);\n        var pushContainerImage = pushContainerImageNeeded(containerImageConfig, pushRequest);\n\n        if (buildContainerImage || pushContainerImage) {\n            if (!containerRuntimeStatusBuildItem.isContainerRuntimeAvailable()) {\n                throw new RuntimeException(\n                        \"Unable to build container image. Please check your %s installation.\"\n                                .formatted(getProcessorImplementation()));\n            }\n\n            if (!NativeBinaryUtil.nativeIsLinuxBinary(nativeImage)) {\n                throw new RuntimeException(\n                        \"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.\");\n            }\n\n            if (buildContainerImage) {\n                LOGGER.infof(\"Starting (local) container image build for native binary using %s\",\n                        getProcessorImplementation());\n            }\n\n            var executableName = getExecutableName(config, containerRuntimes);\n            var dockerfilePaths = getDockerfilePaths(config, true, packageConfig, out);\n            var builtContainerImage = createContainerImage(containerImageConfig, config, containerImage, out, dockerfilePaths,\n                    buildContainerImage, pushContainerImage, packageConfig, executableName);\n\n            // a pull is not required when using this image locally because the strategy always builds the container image\n            // locally before pushing it to the registry\n            artifactResultProducer.produce(\n                    new ArtifactResultBuildItem(\n                            null,","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java#L205-L241","documentation":"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.","triggerScenarios":"Running a native build locally on macOS/Windows without quarkus.native.container-build=true, then building a container image from the resulting native binary.","commonSituations":"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.","solutions":["Add -Dquarkus.native.container-build=true to the native build so GraalVM runs inside a Linux container and produces a Linux binary","Or build natively inside a Linux environment/CI runner","Set quarkus.native.container-build=true in application.properties for local native builds","Rebuild the native image after enabling the flag; the check re-runs on the new binary"],"exampleFix":"# before\n./mvnw package -Dnative -Dquarkus.container-image.build=true\n# after\n./mvnw package -Dnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true","handlingStrategy":"validation","validationCode":"String fileOut = new String(ProcessHelpers.exec(\"file\", \"target/quarkus-app/...-runner\").readAllBytes());\nif (!fileOut.contains(\"ELF\")) {\n    throw new IllegalStateException(\"Native binary is not Linux; rebuild with -Dquarkus.native.container-build=true\");\n}","typeGuard":"boolean isLinuxNativeBinary(Path runner, ProcessExecutor exec) throws Exception {\n    String out = exec.run(\"file\", runner.toString());\n    return out.contains(\"ELF\") && out.contains(\"x86-64\") || out.contains(\"ELF\") && out.contains(\"aarch64\");\n}","tryCatchPattern":"try {\n    jibOrDockerNativeBuild();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not a Linux binary\")) {\n        throw new IllegalStateException(\"Rebuild natively with quarkus.native.container-build=true\", e);\n    }\n    throw e;\n}","preventionTips":["Always pass -Dquarkus.native.container-build=true when building natively on macOS/Windows","Run 'file target/*-runner' to confirm ELF output before container builds","Set quarkus.native.container-build=true in application.properties for container-targeted builds","Build native images in Linux CI runners"],"tags":["native-image","docker","cross-platform","graalvm"],"backgroundTag":"native-binary-not-linux","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}