Docker build fails: "Could not read Dockerfile" even though the existing path and file are correct.

I’m encountering a persistent error during Docker build. The build constantly fails with:

Error: Could not resolve: Could not read Dockerfile: Open Dockerfile: No such file or directory.

The confusing part:
The log shows that it successfully clones the repository and transfers the Dockerfile (it even reports its size):

Text: transferring Dockerfile: 683B completed.
What I’ve verified/tested:

The file exists: The Dockerfile is in the root of my repository.
Correct case: The file name is exactly Dockerfile (no extension). Its contents are as follows:

[FROM maven:3.9.6-eclipse-temurin-21 AS build
WORKDIR /app
COPY . .
RUN mvn clean package -DskipTests
FROM eclipse-temurin:21-jdk
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT [“java”, “-jar”, “app.jar”]
CMD [“java”, “-jar”, “target/hangman-backend-0.0.1-SNAPSHOT.jar”]]

I tried using the master and main branches in the configuration. Modifying the file location in both cases.
I modified and tested both with ENTRYPOINT and CMD.
I also tried the following paths: Dockerfile and ./Dockerfile.

Full error snippet:

What could be causing Docker/BuildKit to recognize the Dockerfile during transfer (683B completed) but not open it immediately? Are there hidden permission issues, system configuration quirks, or errors specific to the Dockerfile that I might be overlooking?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.