{"record":{"id":"08b8172a3355baeb","repo":"quarkusio/quarkus","slug":"unable-to-find-root-of-dockerfile-files-consider","errorCode":null,"errorMessage":"Unable to find root of Dockerfile files. Consider adding 'src/main/docker/' to your project root.","messagePattern":"Unable to find root of Dockerfile files\\. Consider adding 'src/main/docker/' to your project root\\.","errorType":"console","errorClass":"IllegalStateException","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":391,"sourceCode":"            return config.dockerfileJvmPath()\n                    .map(dockerfileJvmPath -> ProvidedDockerfile.get(Paths.get(dockerfileJvmPath), outputDirectory))\n                    .orElseGet(() -> (packageConfig.jar().type() == JarType.LEGACY_JAR)\n                            ? DockerfileDetectionResult.detect(DOCKERFILE_LEGACY_JAR, outputDirectory)\n                            : DockerfileDetectionResult.detect(DOCKERFILE_JVM, outputDirectory));\n        }\n    }\n\n    protected interface DockerfilePaths {\n        Path dockerfilePath();\n\n        Path dockerExecutionPath();\n    }\n\n    protected record DockerfileDetectionResult(Path dockerfilePath, Path dockerExecutionPath) implements DockerfilePaths {\n        protected static DockerfilePaths detect(String resource, Path outputDirectory) {\n            var dockerfileToExecutionRoot = findDockerfileRoot(outputDirectory);\n            if (dockerfileToExecutionRoot == null) {\n                throw new IllegalStateException(\n                        \"Unable to find root of Dockerfile files. Consider adding 'src/main/docker/' to your project root.\");\n            }\n\n            var dockerFilePath = dockerfileToExecutionRoot.getKey().resolve(resource);\n            if (!Files.exists(dockerFilePath)) {\n                throw new IllegalStateException(\n                        \"Unable to find Dockerfile %s in %s\"\n                                .formatted(resource, dockerfileToExecutionRoot.getKey().toAbsolutePath()));\n            }\n\n            return new DockerfileDetectionResult(dockerFilePath, dockerfileToExecutionRoot.getValue());\n        }\n\n        private static Map.Entry<Path, Path> findDockerfileRoot(Path outputDirectory) {\n            var mainSourcesRoot = findMainSourcesRoot(outputDirectory);\n            if (mainSourcesRoot == null) {\n                return null;\n            }","sourceCodeStart":373,"sourceCodeEnd":409,"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#L373-L409","documentation":"When no custom Dockerfile is configured, Quarkus auto-detects the default Dockerfiles by locating src/main/docker/ relative to the project root derived from the build output directory. If the project root cannot be found or the docker directory is missing, detect() throws this IllegalStateException.","triggerScenarios":"Building a container image without quarkus.container-image.docker.dockerfile-jvm-path (or -native-path) set while the project lacks a src/main/docker/ directory, or the build runs from an unusual output layout where the sources root cannot be derived from target/ or build/.","commonSituations":"Deleting the generated src/main/docker directory; building with Gradle from a restructured layout; running the build in a packaged/copied tree that no longer contains src/main/docker; project root detection failing when output dir is moved elsewhere.","solutions":["Restore the default Dockerfiles (copy from a freshly generated Quarkus project's src/main/docker/)","Or explicitly set quarkus.container-image.docker.dockerfile-jvm-path (and -native-path) to an existing Dockerfile","Ensure the build runs with the standard Maven/Gradle layout so the project root is detected from the output directory","Create src/main/docker/ in the project root if you intentionally manage Dockerfiles there"],"exampleFix":"# before: directory removed\n# after\nmkdir -p src/main/docker && cp <fresh-project>/src/main/docker/Dockerfile.jvm src/main/docker/","handlingStrategy":"validation","validationCode":"Path dockerDir = Path.of(\"src/main/docker\");\nif (!Files.isDirectory(dockerDir)) {\n    throw new IllegalStateException(\"src/main/docker missing; restore default Dockerfiles or set quarkus.container-image.docker.dockerfile-jvm-path\");\n}","typeGuard":"boolean defaultDockerfilesPresent(Path projectRoot) {\n    return Files.isDirectory(projectRoot.resolve(\"src/main/docker\"))\n        && Files.isRegularFile(projectRoot.resolve(\"src/main/docker/Dockerfile.jvm\"));\n}","tryCatchPattern":"try {\n    buildImage();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"root of Dockerfile\")) {\n        // restore src/main/docker or configure dockerfile-jvm-path\n    } else throw e;\n}","preventionTips":["Keep the generated src/main/docker directory under version control","Configure explicit dockerfile-jvm-path/dockerfile-native-path in non-standard layouts","Do not delete 'unused' Dockerfiles when switching packaging types","Run image builds from the standard project structure"],"tags":["docker","dockerfile","project-layout","quarkus"],"backgroundTag":"dockerfile-not-found","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"}