testcontainers/testcontainers-java · warning
Tried to parse Dockerfile at path
Error message
Tried to parse Dockerfile at path {} but none was found What it means
ParsedDockerfile parses a Dockerfile to find dependent image names (e.g. FROM lines for dependency pre-pulling). If the configured dockerFilePath does not exist, it logs this warning and returns an empty list rather than failing the build. Downstream, the image build may fail because dependencies were not pre-pulled.
Solutions
- Verify the Dockerfile path passed to withDockerfile(...) exists relative to the working directory or classpath
- Check build/resource configuration so the Dockerfile is packaged and available at runtime
- Pass the Dockerfile content inline via withFileFromString if path-based loading is unreliable
Example fix
// before
new ImageFromDockerfile().withDockerfile(Paths.get("Dockefile"))
// after (typo fixed and existence checked)
Path df = Paths.get("Dockerfile");
if (!Files.exists(df)) throw new IllegalStateException("Dockerfile missing: " + df);
new ImageFromDockerfile().withDockerfile(df); Defensive patterns
Strategy: validation
Validate before calling
Path dockerfile = Paths.get("Dockerfile");
if (!Files.exists(dockerfile)) {
throw new IllegalStateException("Dockerfile not found at " + dockerfile.toAbsolutePath());
} Prevention
- Always assert file existence before withDockerfile(...)
- Use absolute paths or classpath resources to avoid working-directory surprises
- Ensure Dockerfiles are included as test resources in build config
When it happens
Trigger: read() checks Files.exists(dockerFilePath) inside the ParsedDockerfile constructor path; triggered when ImageFromDockerfile is built from a Dockerfile path that does not exist on disk.
Common situations: Typo or wrong relative path passed to withDockerfile / ImageFromDockerfile constructor; Dockerfile excluded from the build artifact; running from a different working 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
- Unable to read Dockerfile at path
- Could not load classpath init script
- Could not load classpath init script
- HTTP response code was
- Response: did not match predicate
AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12).
Data as JSON: /api/errors/d958d4d607acd744.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/testcontainers/images/ParsedDockerfile.java:47
private final Path dockerFilePath;
@Getter
private final Set<String> dependencyImageNames;
public ParsedDockerfile(Path dockerFilePath) {
this.dockerFilePath = dockerFilePath;
this.dependencyImageNames = parse(read());
}
@VisibleForTesting
ParsedDockerfile(List<String> lines) {
this.dockerFilePath = Paths.get("dummy.Dockerfile");
this.dependencyImageNames = parse(lines);
}
private List<String> read() {
if (!Files.exists(dockerFilePath)) {
log.warn("Tried to parse Dockerfile at path {} but none was found", dockerFilePath);
return Collections.emptyList();
}
try {
return Files.readAllLines(dockerFilePath);
} catch (IOException e) {
log.warn("Unable to read Dockerfile at path {}", dockerFilePath, e);
return Collections.emptyList();
}
}
private Set<String> parse(List<String> lines) {
Set<String> imageNames = lines
.stream()
.map(FROM_LINE_PATTERN::matcher)
.filter(Matcher::matches)
.map(matcher -> matcher.group("image"))
.collect(Collectors.toSet());View on GitHub (pinned to 8e549514e3)