{"record":{"id":"fe38222b4abd00c0","repo":"testcontainers/testcontainers-java","slug":"unable-to-read-dockerfile-at-path","errorCode":null,"errorMessage":"Unable to read Dockerfile at path {}","messagePattern":"Unable to read Dockerfile at path (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/testcontainers/images/ParsedDockerfile.java","lineNumber":54,"sourceCode":"        this.dependencyImageNames = parse(read());\n    }\n\n    @VisibleForTesting\n    ParsedDockerfile(List<String> lines) {\n        this.dockerFilePath = Paths.get(\"dummy.Dockerfile\");\n        this.dependencyImageNames = parse(lines);\n    }\n\n    private List<String> read() {\n        if (!Files.exists(dockerFilePath)) {\n            log.warn(\"Tried to parse Dockerfile at path {} but none was found\", dockerFilePath);\n            return Collections.emptyList();\n        }\n\n        try {\n            return Files.readAllLines(dockerFilePath);\n        } catch (IOException e) {\n            log.warn(\"Unable to read Dockerfile at path {}\", dockerFilePath, e);\n            return Collections.emptyList();\n        }\n    }\n\n    private Set<String> parse(List<String> lines) {\n        Set<String> imageNames = lines\n            .stream()\n            .map(FROM_LINE_PATTERN::matcher)\n            .filter(Matcher::matches)\n            .map(matcher -> matcher.group(\"image\"))\n            .collect(Collectors.toSet());\n\n        if (!imageNames.isEmpty()) {\n            log.debug(\"Found dependency images in Dockerfile {}: {}\", dockerFilePath, imageNames);\n        }\n        return imageNames;\n    }\n}","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/images/ParsedDockerfile.java#L36-L72","documentation":"ParsedDockerfile.read() calls Files.readAllLines on the Dockerfile; if reading throws IOException (e.g. permission problems, the file disappearing, or it is a directory), it logs this warning and returns an empty dependency list. The image build continues but dependency pre-pulling is skipped.","triggerScenarios":"Files.readAllLines(dockerFilePath) throws IOException inside read(), called from the ParsedDockerfile constructor during ImageFromDockerfile.resolve().","commonSituations":"File deleted between exists() check and read (race); read permission denied; path is actually a directory; filesystem/I/O errors in CI containers with limited mounts.","solutions":["Check filesystem permissions on the Dockerfile (chmod/chown) so the test JVM can read it","Confirm the path is a regular file, not a directory","Re-run the build; if a race with deletion, ensure nothing deletes the Dockerfile during the test"],"exampleFix":"// before\nnew ImageFromDockerfile().withDockerfile(Paths.get(\"/docker/dir\"))\n// after\nPath p = Paths.get(\"/docker/Dockerfile\");\nif (!Files.isRegularFile(p) || !Files.isReadable(p)) throw new IllegalStateException(\"unreadable: \" + p);\nnew ImageFromDockerfile().withDockerfile(p);","handlingStrategy":"validation","validationCode":"Path p = Paths.get(path);\nif (!Files.isRegularFile(p) || !Files.isReadable(p)) {\n    throw new IllegalStateException(\"Dockerfile unreadable: \" + p);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Files.readAllLines(dockerfile);\n} catch (IOException e) {\n    throw new UncheckedIOException(\"Cannot read Dockerfile: \" + dockerfile, e);\n}","preventionTips":["Check permissions on mounted volumes in CI","Don't delete Dockerfiles while tests run","Verify the path is a file, not a directory"],"tags":["testcontainers","dockerfile","io","filesystem"],"backgroundTag":"file-read-failed","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}