Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Cannot locate specified Dockerfile #5823

Closed
jmthvt opened this issue Mar 26, 2018 · 11 comments
Closed

ERROR: Cannot locate specified Dockerfile #5823

jmthvt opened this issue Mar 26, 2018 · 11 comments

Comments

@jmthvt
Copy link

jmthvt commented Mar 26, 2018

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 docker/cli#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

@jmthvt jmthvt changed the title Cannot locate specified Dockerfile ERROR: Cannot locate specified Dockerfile Mar 26, 2018
@shin-
Copy link

shin- commented Mar 26, 2018

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!

@jmthvt
Copy link
Author

jmthvt commented Apr 11, 2018

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

@shin-
Copy link

shin- commented Apr 11, 2018

Make sure you have the latest version of the docker package

@jmthvt
Copy link
Author

jmthvt commented Apr 11, 2018

That's the case:

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

@shin-
Copy link

shin- commented Apr 11, 2018

The Python package, not the Docker engine.

@jmthvt
Copy link
Author

jmthvt commented Apr 11, 2018

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: joffrey@docker.com
License: Apache License 2.0
Location: /usr/local/lib/python2.7/site-packages

@shin-
Copy link

shin- commented Apr 11, 2018

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?

@jmthvt
Copy link
Author

jmthvt commented Apr 12, 2018

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
services:
  devops-test:
    build:
      context: /Users/johndoe/repos/test/devops-test/
      dockerfile: /Users/johndoe/repos/test/devops-test/dockerfile/Dockerfile
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.

@jmthvt
Copy link
Author

jmthvt commented Apr 12, 2018

I will open a dedicated issue.
#5869

@kavir-bheeroo
Copy link

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

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

Switching back to the Stable builds works fine.

Excerpt of my docker-compose.yml file:

build:
      context: .
      dockerfile: ./src/Services/Roster.API/Dockerfile

@shin-
Copy link

shin- commented May 31, 2018

#5969

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants