Compose: ERROR: Cannot locate specified Dockerfile

Created on 26 Mar 2018  ยท  11Comments  ยท  Source: docker/compose

Description of the issue

Since version 1.20.0, compose fails to locate a dockerfile out of the build context. It worked before, and is allowed since Docker 18.03 https://github.com/docker/cli/pull/886

Context information (for bug reports)

docker-compose version 1.20.1, build 5d8c71b
Client:
 Version:   18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:06:22 2018
 OS/Arch:   darwin/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:    Wed Mar 21 23:14:32 2018
  OS/Arch:  linux/amd64
  Experimental: true
networks:
  devops-test: {}
services:
  devops-test:
    build:
      context: /Users/johndoe/repos/test/devops-test/src
      dockerfile: /Users/johndoe/repos/test/devops-test/Dockerfile
    environment:
    image: repo.dkr.ecr.eu-west-1.amazonaws.com/devops-test
    networks:
      devops-test: null
version: '3.0'

Steps to reproduce the issue

  1. Just run docker-compose build with a Dockerfile out of the context.

Observed result

./docker-compose-1.20.1 -f tools/docker/docker-compose.yml build
Building devops-test
ERROR: Cannot locate specified Dockerfile: /Users/johndoe/repos/test/devops-test/Dockerfile
./docker-compose-1.20.0 -f tools/docker/docker-compose.yml build
Building devops-test
ERROR: Cannot locate specified Dockerfile: /Users/johndoe/repos/test/devops-test/Dockerfile

Expected result

./docker-compose-1.19.0 -f tools/docker/docker-compose.yml build
Building devops-test
Step 1/21 : FROM alpine:3.7
3.7: Pulling from library/alpine

Stacktrace / full error message

(if applicable)

Additional information

macOS 10.13.3

arebuild docker-py kinfeature

Most helpful comment

Thank you for the report!

If this worked before, it was definitely by accident, but I agree that we should keep up with the changes in the engine and support this as well. We'll prioritize accordingly!

All 11 comments

Thank you for the report!

If this worked before, it was definitely by accident, but I agree that we should keep up with the changes in the engine and support this as well. We'll prioritize accordingly!

@shin- I'm getting the same error with docker-compose 1.21.0
docker-compose version 1.21.0, build unknown

Make sure you have the latest version of the docker package

That's the case:

docker --version
Docker version 18.04.0-ce, build 3d479c0

The Python package, not the Docker engine.

pip show docker
Name: docker
Version: 3.2.1
Summary: A Python library for the Docker Engine API.
Home-page: https://github.com/docker/docker-py
Author: Joffrey F
Author-email: [email protected]
License: Apache License 2.0
Location: /usr/local/lib/python2.7/site-packages

I'm not able to reproduce with a similar test case:

$ tree
.
โ”œโ”€โ”€ build
โ”‚ย ย  โ””โ”€โ”€ etc.txt
โ”œโ”€โ”€ dockerfile
โ”‚ย ย  โ””โ”€โ”€ Dockerfile.test
โ””โ”€โ”€ tools
    โ””โ”€โ”€ docker
        โ””โ”€โ”€ docker-compose.yml

4 directories, 3 files
$ docker-compose -f tools/docker/docker-compose.yml config
networks:
  devops-test: {}
services:
  test:
    build:
      context: /home/joffrey/work/tests/compose/repro5823/build
      dockerfile: /home/joffrey/work/tests/compose/repro5823/dockerfile/Dockerfile.test
    command: cat /src/etc.txt
    networks:
      devops-test: null
version: '3.0'

$ docker-compose -f tools/docker/docker-compose.yml build --no-cache 
Building test
Step 1/2 : FROM alpine
 ---> 3fd9065eaf02
Step 2/2 : COPY . /src
 ---> 8df304d51bdf
Successfully built 8df304d51bdf
Successfully tagged docker_test:latest

Is there anything I'm missing that would account for the discrepancy? Are you seeing the same result with the binary distribution?

OK, I think I have isolated the issue.

This test case works, which is context and dockerfile in different folders:

services:
  devops-test:
    build:
      context: /Users/johndoe/repos/test/devops-test/
      dockerfile: /Users/johndoe/repos/test/devops-test/Dockerfile

But now it's failing when the dockerfile is in the context or context's subfolder!

services:
  devops-test:
    build:
      context: /Users/johndoe/repos/test/devops-test/
      dockerfile: /Users/johndoe/repos/test/devops-test/Dockerfile
Building devops-test
ERROR: Cannot locate specified Dockerfile /Users/johndoe/repos/test/devops-test/Dockerfile



md5-e6dc3980fa240bea35e8a5dd521f4904



services:
  devops-test:
    build:
      context: /Users/johndoe/repos/test/devops-test/
      dockerfile: /Users/johndoe/repos/test/devops-test/dockerfile/Dockerfile



md5-e6dc3980fa240bea35e8a5dd521f4904



Building devops-test
ERROR: Cannot locate specified Dockerfile /Users/johndoe/repos/test/devops-test/dockerfile/Dockerfile

The Dockerfile is being looked up if unspecified in compose, but this is still an issue if you need an alternate Dockerfile.

I will open a dedicated issue.
https://github.com/docker/compose/issues/5869

I am getting the Cannot locate specified Dockerfile when switching to the Docker Edge version.

  • docker-compose version 1.21.2, build a1334711
  • docker-py version: 3.3.0

Switching back to the Stable builds works fine.

Excerpt of my docker-compose.yml file:
```yaml
build:
context: .
dockerfile: ./src/Services/Roster.API/Dockerfile

5969

Was this page helpful?
0 / 5 - 0 ratings