Daniel
Daniel

Reputation: 15413

ERROR: Cannot locate specified Dockerfile: Dockerfile

I run this:

➜  frontend git:(master) ✗ docker-compose up
Building web
ERROR: Cannot locate specified Dockerfile: Dockerfile

And I get the error above. This is my directory:

➜  frontend git:(master) ✗ ls
Dockerfile.dev     docker-compose.yml package.json       src
README.md          node_modules       public             yarn.lock

This is my docker-compose.yml file:

version: '3'
services: 
  web: 
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - "3000:3000"
    volumes:
      - /app/node_modules
      - .:/app

Is it an indentation issue? I know YAML is funny about that.

This is my Dockerfile.dev:

 FROM node:alpine

 WORKDIR '/app'

 COPY package.json .
 RUN npm install

 COPY . .

 CMD ["npm", "run", "start"]

I am following documentation: https://docs.docker.com/compose/compose-file/#context

Upvotes: 13

Views: 23964

Answers (3)

ilyas Jumadurdyew
ilyas Jumadurdyew

Reputation: 930

This happens if you mv or copy docker-file from another location. Try just to rename it even if it's Dockerfile already

mv Dockerfile Dockerfile

Upvotes: 2

Aviv
Aviv

Reputation: 14477

Error:

ERROR: Cannot locate specified Dockerfile: Dockerfile

Explanation: In short, Your docker can not locate the docker file which is case sensitive, it perhaps because its not written correctly (some bad examples :DockerFile , dockerfile, Dockerfile.txt , .DockerFile etc...). another option might related to the file location not in the correct path.

Solution: Rename the Dockerfile (The correct spell is Dockerfile) an d make sure you're running it in the project location.

For example:

cd ~/<projectPath>
ls -la
#Relevant files Validation
#drwxr-xr-x  7 myUser  staff  224 Dec 18 11:38 ..
#-rw-r--r--  1 myUser  staff  312 Dec 18 11:40 Dockerfile
#-rw-r--r--  1 myUser  staff  224 Dec 18 11:38 app.py
docker build .

Upvotes: 17

Daniel
Daniel

Reputation: 15413

It appears that Dockerfile.dev is not recognized by Docker hence the message:

ERROR: Cannot locate specified Dockerfile: Dockerfile

It's looking for a Dockerfile not a Dockerfile.dev.

When I tried mv Dockerfile.dev Dockerfile and then ran docker-compose up, it worked as expected.

Upvotes: 4

Related Questions