quarkusio/quarkus · error · IllegalArgumentException

Specified Dockerfile: '%s' does not exist.

Error message

Specified Dockerfile: '%s' does not exist.

What it means

ApplyDockerfileToBuildConfigDecorator.validate() checks that the Dockerfile path supplied for an OpenShift docker build actually exists before using it. If java.io.File.exists() is false it throws IllegalArgumentException. OpenShift's docker build strategy (quarkus.openshift.build-strategy=docker) relies on this decorator to inline the Dockerfile into the BuildConfig.

Source

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

import io.dekorate.kubernetes.decorator.NamedResourceDecorator;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.openshift.api.model.BuildConfigSpecFluent;
import io.quarkus.deployment.util.FileUtil;

public class ApplyDockerfileToBuildConfigDecorator extends NamedResourceDecorator<BuildConfigSpecFluent<?>> {

    private final Path pathToDockerfile;

    public ApplyDockerfileToBuildConfigDecorator(String name, Path pathToDockerfile) {
        super(name);
        validate(pathToDockerfile);
        this.pathToDockerfile = pathToDockerfile;
    }

    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() + "'");

View on GitHub (pinned to e1c734241f)

Solutions

  1. Correct the quarkus.openshift.dockerfile path (default is src/main/docker/Dockerfile) — verify the file exists at the printed absolute path
  2. Use a path relative to the module root or an absolute path in application.properties
  3. Commit the Dockerfile to version control so CI/CD environments have it
  4. If the file is generated, ensure the generator runs before the openshift build/deploy goal

Example fix

// before: application.properties (file actually at src/main/docker/Dockerfile.jvm)
quarkus.openshift.dockerfile=Dockerfile
// after: correct path
quarkus.openshift.dockerfile=src/main/docker/Dockerfile.jvm
Defensive patterns

Strategy: validation

Validate before calling

// before deploying to OpenShift with a custom Dockerfile
java.nio.file.Path df = java.nio.file.Path.of(
    System.getProperty("quarkus.openshift.dockerfile", "src/main/docker/Dockerfile"));
if (!java.nio.file.Files.isRegularFile(df)) {
    throw new IllegalStateException("Dockerfile missing: " + df.toAbsolutePath());
}

Try / catch

try {
    openshiftDeploy();
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().contains("does not exist")) {
        throw new IllegalStateException("Fix quarkus.openshift.dockerfile path in application.properties", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: quarkus.openshift.dockerfile (or programmatic ApplyDockerfileToBuildConfigDecorator construction) points at a path that does not exist on disk at build/deployment time.

Common situations: Typo in quarkus.openshift.dockerfile value, path relative to the wrong working directory (must resolve from the module/project dir), Dockerfile not committed to the repo so CI lacks it, running the deploy goal from a different module directory.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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