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

`docker-compose config` does not use `--project-directory` for build context absolute path #5986

Closed
mshang opened this issue May 24, 2018 · 1 comment

Comments

@mshang
Copy link

@mshang mshang commented May 24, 2018

Description of the issue

docker-compose config turns relative paths in the build context field of the input config into absolute paths. In doing so, the --project-directory setting is ignored.

Context information (for bug reports)

$ docker-compose version
docker-compose version 1.21.2, build a133471
docker-py version: 3.3.0
CPython version: 2.7.10
OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
$ docker version
Client:
 Version:	17.12.0-ce
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	c97c6d6
 Built:	Wed Dec 27 20:03:51 2017
 OS/Arch:	darwin/amd64

Server:
 Engine:
  Version:	17.12.0-ce
  API version:	1.35 (minimum version 1.12)
  Go version:	go1.9.2
  Git commit:	c97c6d6
  Built:	Wed Dec 27 20:12:29 2017
  OS/Arch:	linux/amd64
  Experimental:	true
$ docker-compose config
services:
  abc:
    build:
      context: /Users/mshang/test_dc_config
version: '2.0'

Steps to reproduce the issue

  1. Set up a directory with these files:
$ cat docker-compose.yaml
version: '2'

services:
  abc:
    build: .
$ cat subdir/Dockerfile
FROM alpine:3.7

RUN echo abc > /root/abc
  1. Build with --project-directory works:
docker-compose --project-directory subdir build
Building abc
Step 1/2 : FROM alpine:3.7
 ---> 3fd9065eaf02
Step 2/2 : RUN echo abc > /root/abc
 ---> Using cache
 ---> a1336194faf5
Successfully built a1336194faf5
Successfully tagged subdir_abc:latest
  1. Building from the config generated by docker-compose config with --project-directory does not work:
$ docker-compose --project-directory subdir config | tee /tmp/dc.yaml
services:
  abc:
    build:
      context: /Users/mshang/test_dc_config
version: '2.0'
$ docker-compose --file /tmp/dc.yaml build
Building abc
ERROR: Cannot locate specified Dockerfile: Dockerfile
$ docker-compose --file /tmp/dc.yaml --project-directory subdir build
Building abc
ERROR: Cannot locate specified Dockerfile: Dockerfile

Observed result

  • Generated config does not reference subdir.
  • Build fails.

Expected result

  • Build context field in generated config should point to /Users/mshang/test_dc_config/subdir.
  • Build should succeed.

Stacktrace / full error message

See above.

Additional information

MacOS 10.11.6, docker-compose installed using pip, running Docker for Mac.

@shin-

This comment has been minimized.

Copy link
Contributor

@shin- shin- commented May 24, 2018

--project-directory being ignored is a known issue - see #4841 for details.

@shin- shin- closed this May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.