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
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'
./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
./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
(if applicable)
macOS 10.13.3
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.
Switching back to the Stable builds works fine.
Excerpt of my docker-compose.yml file:
```yaml
build:
context: .
dockerfile: ./src/Services/Roster.API/Dockerfile
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!