{"record":{"id":"c8e904e61ce3a325","repo":"quarkusio/quarkus","slug":"specified-dockerfile-s-does-not-contain-a-from","errorCode":null,"errorMessage":"Specified Dockerfile: '%s' does not contain a FROM directive","messagePattern":"Specified Dockerfile: '(.+?)' does not contain a FROM directive","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/ApplyDockerfileToBuildConfigDecorator.java","lineNumber":44,"sourceCode":"    }\n\n    private void validate(Path pathToDockerfile) {\n        File file = pathToDockerfile.toFile();\n        if (!file.exists()) {\n            throw new IllegalArgumentException(\n                    \"Specified Dockerfile: '\" + pathToDockerfile.toAbsolutePath().toString() + \"' does not exist.\");\n        }\n        if (!file.isFile()) {\n            throw new IllegalArgumentException(\n                    \"Specified Dockerfile: '\" + pathToDockerfile.toAbsolutePath().toString() + \"' is not a normal file.\");\n        }\n\n        try {\n            Stream<String> lines = Files.lines(pathToDockerfile);\n            Optional<String> fromLine = lines.filter(l -> !l.startsWith(\"#\")).map(String::trim)\n                    .filter(l -> l.startsWith(\"FROM\")).findFirst();\n            if (!fromLine.isPresent()) {\n                throw new IllegalArgumentException(\"Specified Dockerfile: '\" + pathToDockerfile.toAbsolutePath().toString()\n                        + \"' does not contain a FROM directive\");\n            }\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\n                    \"Unable to validate specified Dockerfile: '\" + pathToDockerfile.toAbsolutePath().toString() + \"'\");\n        }\n    }\n\n    @Override\n    public void andThenVisit(final BuildConfigSpecFluent<?> spec, ObjectMeta meta) {\n        try (InputStream is = new FileInputStream(pathToDockerfile.toFile())) {\n            spec.withNewSource()\n                    .withDockerfile(new String(FileUtil.readFileContents(is)))\n                    .endSource()\n                    .withNewStrategy()\n                    .withNewDockerStrategy()\n                    .endDockerStrategy()\n                    .endStrategy();","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/ApplyDockerfileToBuildConfigDecorator.java#L26-L62","documentation":"After existence checks, validate() scans the Dockerfile for a non-comment line starting with FROM. If none is found it throws IllegalArgumentException — OpenShift docker builds need the FROM line to derive the base image for the BuildConfig. A Dockerfile without FROM is invalid input for this decorator.","triggerScenarios":"The configured Dockerfile exists and is a regular file, but its content has no FROM instruction — e.g. it only contains ARG-based FROM with the value missing/never matched because lines start with whitespace handled? No: lines are trimmed, so the real causes are: FROM written as 'from' (lowercase, filter is case-sensitive), FROM only inside build ARGs never literally present, or an empty/wrong file with similar name.","commonSituations":"Lowercase 'from' directive (case-sensitive check), Dockerfiles relying solely on ARG BASE_IMAGE without a literal FROM line, accidentally configuring a Dockerfile fragment/override file (e.g. docker-compose override) instead of the real Dockerfile.","solutions":["Ensure the Dockerfile has a literal FROM line (uppercase FROM at start of a non-comment line)","Do not put the base image only in an ARG used by FROM without a literal FROM present — write FROM directly","Check for typos/lowercase 'from' and comment-only files","Verify you configured the intended Dockerfile, not a fragment"],"exampleFix":"// before: Dockerfile\nARG BASE_IMAGE=registry.access.redhat.com/ubi8/openjdk-17\nFROM ${BASE_IMAGE}\n# (works only if FROM is literal — but if FROM was 'from' or absent entirely:)\n// after: ensure a literal FROM directive\nFROM registry.access.redhat.com/ubi8/openjdk-17:1.19","handlingStrategy":"validation","validationCode":"// pre-validate the Dockerfile has a FROM directive\ntry (var lines = java.nio.file.Files.lines(java.nio.file.Path.of(dockerfile))) {\n    boolean hasFrom = lines.filter(l -> !l.startsWith(\"#\")).map(String::trim)\n            .anyMatch(l -> l.startsWith(\"FROM\"));\n    if (!hasFrom) throw new IllegalStateException(\"Dockerfile lacks a FROM directive: \" + dockerfile);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a literal uppercase FROM line","Do not rely solely on ARG-provided base images for OpenShift builds","Review the exact Dockerfile configured — not fragments or override files"],"tags":["openshift","dockerfile","validation","docker"],"backgroundTag":"dockerfile-missing-from-directive","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"}