docker-compose gives ERROR: Cannot locate specified Dockerfile: Dockerfile

You need to specify the docker file name properly and it is case sensitive. I had uppercase letter in DockerFile and so it cannot find them. Hope it helps someone, who struggled like me. Better to use the dockerfile attribute in docker compose file.

app:
    build:
      dockerfile: DockerFile

I had this problem on Windows with a docker-compose.yml created by a Visual Studio template. The template was created as:

build:
  context: .
  dockerfile: <ProjectFolder>\Dockerfile

And I was getting error: Cannot locate specified Dockerfile: <ProjectFolder>\Dockerfile. I changed the \ to / and it started working for me (i.e. <ProjectFolder>/Dockerfile). Maybe that will help if anyone has this error on Windows.


Here is how to specify dockerfile. Sorry I cannot do it in comments as formatting is not supported over there.

The dockerfile is searched into the defined build context, that is, you don't specify any path, just the filename of your Dockerfile.

https://docs.docker.com/compose/compose-file/#context

app:
    build:
      context: app
      dockerfile: Dockerfile

Inside the docker-compose.yml file to do the change, in order to meet the Dockerfile:

app:
  build: ./app