Compose: build with context and dockerfile fails due to cannot locate specified dockerfile for version 1.21.2

Created on 17 May 2018  ·  11Comments  ·  Source: docker/compose

Description of the issue

Running docker-compose build results in:

ERROR: Cannot locate specified Dockerfile: .dockerfile\test\Dockerfile

Context information (for bug reports)

docker-compose version 1.21.2, build a1334711
Client:
 Version:      18.05.0-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   f150324
 Built:        Wed May  9 22:12:05 2018
 OS/Arch:      windows/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.05.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.10.1
  Git commit:   f150324
  Built:        Wed May  9 22:20:16 2018
  OS/Arch:      linux/amd64
  Experimental: true
services:
  test:
    build:
      context: C:\Users\ltheisen\git\lucastheisen-docker-compose-fail
      dockerfile: ./.dockerfile/test/Dockerfile
version: '3.0'

Steps to reproduce the issue

  1. Clone this repo
  2. Run docker-compose build

Observed result

ERROR: Cannot locate specified Dockerfile: .dockerfile\test\Dockerfile

Expected result

Successful build

Stacktrace / full error message

PS C:\Users\ltheisen\git\lucastheisen-docker-compose-fail> docker-compose --verbose build
compose.config.config.find: Using configuration files: .\docker-compose.yml
docker.utils.config.find_config_file: Trying paths: ['C:\\Users\\ltheisen\\.docker\\config.json', 'C:\\Users\\ltheisen\\.dockercfg']
docker.utils.config.find_config_file: Found file at path: C:\Users\ltheisen\.docker\config.json
docker.auth.load_config: Found 'auths' section
docker.auth.parse_auth: Auth data for https://index.docker.io/v1/ is absent. Client might be using a credentials store instead.
docker.auth.load_config: Found 'credsStore' section
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/version HTTP/1.1" 200 568
compose.cli.command.get_client: docker-compose version 1.21.2, build a1334711
docker-py version: 3.3.0
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.0.2k  26 Jan 2017
compose.cli.command.get_client: Docker base_url: http+docker://localnpipe
compose.cli.command.get_client: Docker version: Platform={'Name': ''}, Components=[{'Name': 'Engine', 'Version': '18.05.0-ce', 'Details': {'ApiVersion': '1.37', 'Arch': 'amd64', 'BuildTime': '2018-05-09T22:20:16.000000000+00:00', 'Experimental': 'true', 'GitCommit': 'f150324', 'GoVersion': 'go1.10.1', 'KernelVersion': '4.9.87-linuxkit-aufs', 'MinAPIVersion': '1.12', 'Os': 'linux'}}], Version=18.05.0-ce, ApiVersion=1.37, MinAPIVersion=1.12, GitCommit=f150324, GoVersion=go1.10.1, Os=linux, Arch=amd64, KernelVersion=4.9.87-linuxkit-aufs, Experimental=True, BuildTime=2018-05-09T22:20:16.000000000+00:00
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('lucastheisendockercomposefail_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/networks/lucastheisendockercomposefail_default HTTP/1.1" 404 70
compose.service.build: Building test
compose.cli.verbose_proxy.proxy_callable: docker build <- (path='C:\\Users\\ltheisen\\git\\lucastheisen-docker-compose-fail', tag='lucastheisen-docker-compose-fail_test', rm=True, forcerm=False, pull=False, nocache=False, dockerfile='./.dockerfile/test/Dockerfile', cache_from=None, labels=None, buildargs={}, network_mode=None, target=None, shmsize=None, extra_hosts=None, container_limits={'memory': None}, gzip=False, isolation=None, platform=None)
docker.api.build._set_auth_headers: Looking for auth config
docker.auth.resolve_authconfig: Using credentials store "wincred"
docker.auth._resolve_authconfig_credstore: Looking for auth entry for 'https://index.docker.io/v1/'
docker.api.build._set_auth_headers: Sending auth config ('https://index.docker.io/v1/')
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/build?t=lucastheisen-docker-compose-fail_test&q=False&nocache=False&rm=True&forcerm=False&pull=False&dockerfile=.dockerfile%5Ctest%5CDockerfile HTTP/1.1" 500 80
compose.cli.verbose_proxy.proxy_callable: docker build -> <generator object APIClient._stream_helper at 0x000001AAA1D7D1A8>
ERROR: compose.cli.errors.log_api_error: Cannot locate specified Dockerfile: .dockerfile\test\Dockerfile

Additional information

OS version / distribution, docker-compose install method, etc.
OS: Windows 1709
Install method: choco install docker-for-windows

grouwindows-client kinbug

Most helpful comment

Found the issue, which should be fixed by https://github.com/docker/docker-py/pull/2038

All 11 comments

This works in 1.18.0, so definitely a regression:

PS C:\Users\MWatkins\tmp\compose-fail\docker-compose-fail> docker-compose build
Building test
Step 1/1 : FROM alpine
 ---> 3fd9065eaf02
Successfully built 3fd9065eaf02
Successfully tagged dockercomposefail_test:latest
PS C:\Users\MWatkins\tmp\compose-fail\docker-compose-fail> docker-compose --version
docker-compose version 1.18.0, build 8dd22a96
PS C:\Users\MWatkins\tmp\compose-fail\docker-compose-fail>

I'm experiencing the same exact behavior.

Got this error in Docker Compose 1.21.2 that comes with Docker Community Edition 18.05.0-ce-win66 2018-05-17. I upgraded to this version yesterday (2018-05-17). There were no errors prior to the upgrade.

Reverted back to Docker Compose 1.21.0 that comes with Docker Community Edition 18.05.0-ce-rc1-win63 2018-04-26, and everything works fine.

Observations:

in 1.21.2, this is happening if the build.dockerfile in docker-compose.yml has a value of the format {folder}/Dockerfile.

services:
  servicename:
    image: imagename
    build:
      context: .
      dockerfile: folder/Dockerfile

if the value is changed to just the docker file name, and build.context is modified to include the folder path, it works fine. (not sure if this is the intended behavior going forward. i.e dockerfile cannot have folder name in the value)

services:
  servicename:
    image: imagename
    build:
      context: ./folder
      dockerfile: Dockerfile

+1 (on the problem, and it being a regression)

+1 hit this issue today on windows for docker 18.05.0-ce-win66 (17760) Compose 1.21.2.
Had to roll back to stable

Double checked it is work on windows for docker 18.03.1-ce-win65 (17513) Compose 1.21.1

@mathewrg Your example works fine for me:

$ tree
.
├── docker-compose.yml
└── test
    └── Dockerfile

1 directory, 2 files
# cat docker-compose.yml 
version: '2.4'
services:
  foo:
    build:
      context: .
      dockerfile: test/Dockerfile
    image: foobar:123



md5-c852e776717232dc09e0845cd0a0147c



$ docker-compose build
Building foo
Step 1/2 : FROM busybox
 ---> f6e427c148a7
Step 2/2 : RUN echo "hello world"
 ---> Using cache
 ---> 99e292b48901

Successfully built 99e292b48901
Successfully tagged foobar:123

Am I missing something here?

@shin- this happened to me for a .net core project in VS2017 15.7.1.

just noticed that I have version 3.4 in my docker-compose.yml and you have it as 2.4.

similar issue is opened here, with one of the comments mentioning the same workaround.

@shin- I have had multiple people verify this... Could you try the test project I linked to above? Perhaps it has something to do with the dockerfile path containing a folder with . in the name?

@lucastheisen Your example works fine as well. It's probably a Windows-specific issue. I'll investigate more.

$ git clone [email protected]:lucastheisen/docker-compose-fail.git
Cloning into 'docker-compose-fail'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
Checking connectivity... done.
$ cd docker-compose-fail/
$ docker-compose build
Building test
Step 1/1 : FROM alpine
 ---> 3fd9065eaf02
Successfully built 3fd9065eaf02
Successfully tagged docker-compose-fail_test:latest

Found the issue, which should be fixed by https://github.com/docker/docker-py/pull/2038

Was this page helpful?
0 / 5 - 0 ratings

Related issues

29e7e280-0d1c-4bba-98fe-f7cd3ca7500a picture 29e7e280-0d1c-4bba-98fe-f7cd3ca7500a  ·  3Comments

davidbarratt picture davidbarratt  ·  3Comments

guycalledseven picture guycalledseven  ·  3Comments

bergtwvd picture bergtwvd  ·  3Comments

maltefiala picture maltefiala  ·  3Comments