Compose: 'Cannot locate specified Dockerfile: Dockerfile' on build instruction

Created on 22 Apr 2015  路  8Comments  路  Source: docker/compose

Running docker-compose up with a build instruction gives me the following error (verbose mode):

Creating flb_api_1...
docker containers <- (all=True)
docker containers -> (list with 2 items)
docker containers <- (all=False)
docker containers -> (list with 2 items)
docker containers <- (all=False)
docker containers -> (list with 2 items)
docker images <- (name=u'flb_api')
docker images -> (list with 0 items)
Building api...
docker build <- (u'/home/core/flb', rm=True, tag=u'flb_api', nocache=False, stream=True)
docker build -> <generator object _stream_helper at 0x2578820>
Cannot locate specified Dockerfile: Dockerfile

The corresponding docker-compose.yml:

api:
  build: .
  links:
  - db
  - cache
db:
  image: postgres
cache:
  image: redis

My docker-compose.yml is stored in the same directory as the Dockerfile.

/home/core/flb
|_  Dockerfile
|_  docker-compose.yml
|_  ...

Tested on both Linux and Max OS X.

kinbug

Most helpful comment

I found why. My .dockerignore file contains the Dockerfile.
Is that a bug or a feature? :)

All 8 comments

I found why. My .dockerignore file contains the Dockerfile.
Is that a bug or a feature? :)

https://github.com/docker/docker-py/issues/498 was added to docker-py 1.1.0, but compose is still using 1.0.0. It'll be upgraded soon enough to support other featuers, which should fix this.

Happens to me as well with:
docker-compose 1.2.0 and docker version 1.6.0, build 4749651

This will be fixed in the next release when we upgrade docker-py.

I'm running compose 1.4.0 and docker 1.7.1, and this issue is still around. I removed the offending line from .dockerignore as a workaround for now. I suggest not closing issues until problems are actually resolved.

@sirpengi Steps to reproduce, please?

$ ls -a
.                  ..                 .dockerignore      Dockerfile         docker-compose.yml

$ cat .dockerignore
Dockerfile

$ cat Dockerfile
FROM busybox

$ cat docker-compose.yml
web:
  build: .

$ docker build .
Sending build context to Docker daemon 4.096 kB
Step 0 : FROM busybox
 ---> 8c2e06607696
Successfully built 8c2e06607696

$ docker-compose build
Building web...
Step 0 : FROM busybox
 ---> 8c2e06607696
Successfully built 8c2e06607696

$ docker-compose version
docker-compose version: 1.4.0
docker-py version: 1.3.1
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1j 15 Oct 2014

$ docker version
Client:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      linux/amd64

I'm on 14.04 LTS and I track the official docker apt repo so my docker version is 1.7.1, but in any case the problem is with docker-compose:

$ ls -a
.  ..  docker-compose.yml  Dockerfile.alt  .dockerignore

$ cat .dockerignore
Dockerfile.alt

$ cat Dockerfile.alt
FROM busybox

$ cat docker-compose.yml
lol:
  dockerfile: Dockerfile.alt
  build: .

$ docker build -f Dockerfile.alt .
Sending build context to Docker daemon 4.096 kB
Sending build context to Docker daemon
Step 0 : FROM busybox
 ---> 8c2e06607696
Successfully built 8c2e06607696

$ docker-compose build
Building lol...
Cannot locate specified Dockerfile: Dockerfile.alt

$ docker-compose version
docker-compose version: 1.4.0
docker-py version: 1.3.1
CPython version: 2.7.6
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014

$ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64

@sirpengi I found the bug in docker-py and opened https://github.com/docker/docker-py/issues/730

Was this page helpful?
0 / 5 - 0 ratings