quarkusio/quarkus · error · IllegalStateException
Unable to find Dockerfile %s in %s
Error message
Unable to find Dockerfile %s in %s
What it means
The default-Dockerfile detection found the docker directory root but the specific expected Dockerfile resource (e.g. Dockerfile.jvm, Dockerfile.legacy-jar, Dockerfile.native) does not exist in it, so detect() throws this IllegalStateException naming the missing file and the absolute root path.
Source
Thrown at extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java:397
}
protected interface DockerfilePaths {
Path dockerfilePath();
Path dockerExecutionPath();
}
protected record DockerfileDetectionResult(Path dockerfilePath, Path dockerExecutionPath) implements DockerfilePaths {
protected static DockerfilePaths detect(String resource, Path outputDirectory) {
var dockerfileToExecutionRoot = findDockerfileRoot(outputDirectory);
if (dockerfileToExecutionRoot == null) {
throw new IllegalStateException(
"Unable to find root of Dockerfile files. Consider adding 'src/main/docker/' to your project root.");
}
var dockerFilePath = dockerfileToExecutionRoot.getKey().resolve(resource);
if (!Files.exists(dockerFilePath)) {
throw new IllegalStateException(
"Unable to find Dockerfile %s in %s"
.formatted(resource, dockerfileToExecutionRoot.getKey().toAbsolutePath()));
}
return new DockerfileDetectionResult(dockerFilePath, dockerfileToExecutionRoot.getValue());
}
private static Map.Entry<Path, Path> findDockerfileRoot(Path outputDirectory) {
var mainSourcesRoot = findMainSourcesRoot(outputDirectory);
if (mainSourcesRoot == null) {
return null;
}
var dockerfilesRoot = mainSourcesRoot.getKey().resolve(DOCKER_DIRECTORY_NAME);
if (!dockerfilesRoot.toFile().exists()) {
return null;
}
View on GitHub (pinned to e1c734241f)
Solutions
- Restore the missing Dockerfile into src/main/docker/ from a generated Quarkus project
- Set quarkus.container-image.docker.dockerfile-jvm-path (or -native-path) to point at the Dockerfile you actually have
- Match the package type configuration (quarkus.package.jar.type) with the Dockerfiles present
- Check the absolute path in the message to confirm which directory and filename are expected
Example fix
# before: only Dockerfile.jvm present, legacy-jar build ./mvnw package -Dquarkus.package.jar.type=legacy-jar -Dquarkus.container-image.build=true # after cp Dockerfile.jvm Dockerfile.legacy-jar # or set quarkus.container-image.docker.dockerfile-jvm-path=Dockerfile.jvm
Defensive patterns
Strategy: validation
Validate before calling
String pkgType = System.getProperty("quarkus.package.jar.type", "fast-jar");
String expected = pkgType.equals("legacy-jar") ? "Dockerfile.legacy-jar"
: "Dockerfile.jvm";
if (!Files.isRegularFile(Path.of("src/main/docker", expected))) {
throw new IllegalStateException("Missing " + expected + " in src/main/docker");
} Type guard
boolean dockerfileExistsFor(String name) {
return Files.isRegularFile(Path.of("src/main/docker", name));
} Try / catch
try {
buildImage();
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Unable to find Dockerfile")) {
// restore file or set quarkus.container-image.docker.dockerfile-jvm-path
} else throw e;
} Prevention
- Keep all generated Dockerfiles (jvm, legacy-jar, native, native-micro) in src/main/docker
- When setting quarkus.package.jar.type=legacy-jar, ensure Dockerfile.legacy-jar exists
- Point dockerfile-jvm-path at an existing Dockerfile if you maintain your own
- Verify filenames have no stray extensions (.txt) or case mismatches
When it happens
Trigger: src/main/docker/ exists but is missing the Dockerfile matching the package type: Dockerfile.legacy-jar needed when quarkus.package.jar.type=legacy-jar, or Dockerfile.native needed for a native image build, etc.
Common situations: Switching quarkus.package.jar.type to legacy-jar while only Dockerfile.jvm exists; users deleting Dockerfile.native as 'unused'; typos renaming the file (Dockerfile.jvm.txt).
Related errors
- Unable to find root of Dockerfile files. Consider adding 'sr
- Unable to determine project root
- Specified Dockerfile path %s does not exist
- Specified Dockerfile: '%s' does not contain a FROM directive
- Serialized application file not found or not readable: ${cac
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a65a4aa3d5c3dca2.
Report an issue: GitHub.