$> pip freeze | grep docker && python --version && docker version
docker==3.2.0
docker-compose==1.20.1
docker-pycreds==0.2.2
dockerpty==0.4.1
Python 3.6.4
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.10
Git commit: 0520e24302
Built: Fri Mar 23 01:47:41 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.10
Git commit: 0520e24302
Built: Fri Mar 23 01:48:12 2018
OS/Arch: linux/amd64
Experimental: false
$> pwd
/tmp/tmp.sYItnmyls8
md5-a63031b3fb9ef7bf6de02261a251f0f7
$> tree
.
├── context
│  └── CustomDockerFile
└── docker-compose.yml
md5-a63031b3fb9ef7bf6de02261a251f0f7
$> cat docker-compose.yml
version: "3"
services:
testservice:
build:
context: ./context
dockerfile: CustomDockerFile
md5-a63031b3fb9ef7bf6de02261a251f0f7
$> cat context/CustomDockerFile
FROM scratch
md5-a63031b3fb9ef7bf6de02261a251f0f7
$> docker-compose build
Building testservice
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 11, in <module>
load_entry_point('docker-compose==1.20.1', 'console_scripts', 'docker-compose')()
File "/usr/lib/python3.6/site-packages/compose/cli/main.py", line 71, in main
command()
File "/usr/lib/python3.6/site-packages/compose/cli/main.py", line 127, in perform_command
handler(command, command_options)
File "/usr/lib/python3.6/site-packages/compose/cli/main.py", line 280, in build
build_args=build_args)
File "/usr/lib/python3.6/site-packages/compose/project.py", line 372, in build
service.build(no_cache, pull, force_rm, memory, build_args)
File "/usr/lib/python3.6/site-packages/compose/service.py", line 998, in build
'memory': parse_bytes(memory) if memory else None
File "/usr/lib/python3.6/site-packages/docker/api/build.py", line 154, in build
with open(dockerfile, 'r') as df:
FileNotFoundError: [Errno 2] No such file or directory: 'CustomDockerFile'
This is caused by https://github.com/docker/docker-py/pull/1977/files#diff-e1d542dae5b9c86ba6a8242ebd3f5df6R152 .
path = '/tmp/tmp.sYItnmyls8/context'
dockerfile = 'CustomDockerFile'
os.path.relpath(dockerfile, path) in this context returns '../CustomDockerFile'
Am i missing something evident?
Same issue for me.
I had to downgrade python-docker to version 3.1.4.1 and it works.
Thanks for the report!
Just released 3.2.1 with the fix!
Most helpful comment
Just released 3.2.1 with the fix!