quarkusio/quarkus · error · IllegalArgumentException

Specified Dockerfile: '%s' does not contain a FROM directive

Error message

Specified Dockerfile: '%s' does not contain a FROM directive

What it means

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.

Source

Thrown at extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/ApplyDockerfileToBuildConfigDecorator.java:44

    }

    private void validate(Path pathToDockerfile) {
        File file = pathToDockerfile.toFile();
        if (!file.exists()) {
            throw new IllegalArgumentException(
                    "Specified Dockerfile: '" + pathToDockerfile.toAbsolutePath().toString() + "' does not exist.");
        }
        if (!file.isFile()) {
            throw new IllegalArgumentException(
                    "Specified Dockerfile: '" + pathToDockerfile.toAbsolutePath().toString() + "' is not a normal file.");
        }

        try {
            Stream<String> lines = Files.lines(pathToDockerfile);
            Optional<String> fromLine = lines.filter(l -> !l.startsWith("#")).map(String::trim)
                    .filter(l -> l.startsWith("FROM")).findFirst();
            if (!fromLine.isPresent()) {
                throw new IllegalArgumentException("Specified Dockerfile: '" + pathToDockerfile.toAbsolutePath().toString()
                        + "' does not contain a FROM directive");
            }
        } catch (IOException e) {
            throw new IllegalArgumentException(
                    "Unable to validate specified Dockerfile: '" + pathToDockerfile.toAbsolutePath().toString() + "'");
        }
    }

    @Override
    public void andThenVisit(final BuildConfigSpecFluent<?> spec, ObjectMeta meta) {
        try (InputStream is = new FileInputStream(pathToDockerfile.toFile())) {
            spec.withNewSource()
                    .withDockerfile(new String(FileUtil.readFileContents(is)))
                    .endSource()
                    .withNewStrategy()
                    .withNewDockerStrategy()
                    .endDockerStrategy()
                    .endStrategy();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure the Dockerfile has a literal FROM line (uppercase FROM at start of a non-comment line)
  2. Do not put the base image only in an ARG used by FROM without a literal FROM present — write FROM directly
  3. Check for typos/lowercase 'from' and comment-only files
  4. Verify you configured the intended Dockerfile, not a fragment

Example fix

// before: Dockerfile
ARG BASE_IMAGE=registry.access.redhat.com/ubi8/openjdk-17
FROM ${BASE_IMAGE}
# (works only if FROM is literal — but if FROM was 'from' or absent entirely:)
// after: ensure a literal FROM directive
FROM registry.access.redhat.com/ubi8/openjdk-17:1.19
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate the Dockerfile has a FROM directive
try (var lines = java.nio.file.Files.lines(java.nio.file.Path.of(dockerfile))) {
    boolean hasFrom = lines.filter(l -> !l.startsWith("#")).map(String::trim)
            .anyMatch(l -> l.startsWith("FROM"));
    if (!hasFrom) throw new IllegalStateException("Dockerfile lacks a FROM directive: " + dockerfile);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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