Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Cannot locate specified Dockerfile: Dockerfile

Tags:

docker

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

like image 720
Daniel Avatar asked Feb 01 '19 01:02

Daniel


1 Answers

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 .
like image 175
avivamg Avatar answered Sep 23 '22 02:09

avivamg