docker-compose gives ERROR: Cannot locate specified Dockerfile: Dockerfile
I've cloned a docker setup which uses docker-compose. One remote developer confirms it works so my problem seems to be with my setup.
I ran docker-compose up
, but that currently gives me this:
$ docker-compose up
Creating volume "mycompanydocker_mysql-data" with local driver
Creating volume "mycompanydocker_redis-data" with local driver
Creating volume "mycompanydocker_app-data" with local driver
Creating volume "mycompanydocker_mongo-data" with local driver
mycompanydocker_redis_1 is up-to-date
mycompanydocker_mongo_1 is up-to-date
mycompanydocker_mysql_1 is up-to-date
Building app
ERROR: Cannot locate specified Dockerfile: Dockerfile
My docker-compose.yml
looks like this:
version: '2'
services:
mysql:
build: mysql/.
env_file: env
expose:
- 3306
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
mongo:
build: mongo/.
env_file: env
expose:
- 27017
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
redis:
build: redis/.
env_file: env
expose:
- 6379
ports:
- "6379:6379"
volumes:
- redis-data:/data
app:
build: app/.
env_file: env
expose:
- 80
ports:
- "80:80"
volumes:
# To mount a local directory, change this
# To use a docker volume
- app-data:/app
# local app
# - ./mycompany:/app
depends_on:
- mysql
- mongo
- redis
volumes:
app-data:
driver: local
mysql-data:
driver: local
redis-data:
driver: local
mongo-data:
driver: local
and the tree looks like this:
$ tree
.
├── README.rst
├── app
│ ├── Dockerfile
│ ├── bin
│ │ ├── setup.sh
│ │ ├── start-nginx.sh
│ │ ├── start-rqworker.sh
│ │ ├── start.sh
│ │ └── update.sh
│ ├── etc
│ │ ├── nginx
│ │ │ └── sites-available
│ │ │ └── app
│ │ ├── supervisor
│ │ │ └── conf.d
│ │ │ └── supervisord.conf
│ │ └── supervisord.conf
│ └── ssh
│ └── id_rsa
├── docker-compose.yml
├── env
├── mongo
│ └── Dockerfile
├── mysql
│ └── Dockerfile
└── redis
└── Dockerfile
The thing I don't understand is that docker-compose
seems to find all Dockerfile
s, except for the one in the app
folder. I've got the following installed on OSX 10.11.2:
Docker version 1.10.3, build 20f81dd
docker-compose version 1.6.2, build 4d72027
I'm just starting out with Docker and I'm kinda stuck here. Does anybody know what could possibly be wrong or how I can debug this? All tips are welcome!
[EDIT]
I forgot to mention that there is no hidden .dockerignore
file:
$ ls -la
total 56
drwx------@ 11 kramer staff 374 25 mrt 14:13 .
drwx------+ 1134 kramer staff 38556 26 mrt 17:27 ..
-rw-r--r--@ 1 kramer staff 8196 26 mrt 08:14 .DS_Store
-rw-r--r--@ 1 kramer staff 23 24 mrt 15:29 .gitignore
-rw-r--r--@ 1 kramer staff 3879 24 mrt 15:29 README.rst
drwxr-xr-x@ 7 kramer staff 238 25 mrt 14:26 app
-rw-r--r--@ 1 kramer staff 868 25 mrt 17:50 docker-compose.yml
-rw-r--r--@ 1 kramer staff 219 24 mrt 15:29 env
drwxr-xr-x@ 3 kramer staff 102 24 mrt 15:29 mongo
drwxr-xr-x@ 3 kramer staff 102 24 mrt 15:29 mysql
drwxr-xr-x@ 3 kramer staff 102 24 mrt 15:29 redis
and the .gitignore
file doesn't contain anything special either (don't know if it matters):
$ cat .gitignore
.project
.pydevproject
Here is how to specify dockerfile. Sorry I cannot do it in comments as formatting is not supported over there.
https://docs.docker.com/compose/compose-file/#context
app:
build:
context: app
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.
Inside the docker-compose.yml
file to do the change, in order to meet the Dockerfile:
app:
build: ./app