Compose: Inline default values raise an error with volumes

Created on 6 Oct 2016  路  7Comments  路  Source: docker/compose

After the recent addition of #3108.

See the following :

version: '2.1'
services:

  test:
    container_name: test-name
    image: busybox
    command: "true"
    privileged: true
    volumes:
      - ${DATA_DIR-/home/hadim/test_data_dir}:/data:Z

And the error :

ERROR: Invalid interpolation format for "volumes" option in service "test": "${DATA_DIR-/home/hadim/test_data_dir}:/data:Z"
$ docker version
Client:
 Version:      1.12.2-rc2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   ad9538a
 Built:        Tue Oct  4 18:23:48 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.2-rc2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   ad9538a
 Built:        Tue Oct  4 18:23:48 2016
 OS/Arch:      linux/amd64

$ docker-compose version
docker-compose version 1.9.0dev, build unknown
docker-py version: 1.10.3
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
areconfig kinbug

All 7 comments

cc @dnephin Do you think the parser is confused because of the : character appearing after the ${} section is closed?

Nope, I think the issue is that the regex only expects alphanumeric for the default value. It needs to be extended to [^}]+ I think.

This does not seems to work now. There was any updates related to this approach? Below is my docker-compose version output:

docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

@vkruoso It'd be helpful if you shared your docker-compose.yml - or at least the error message you're seeing.

@shin- Thanks for the fast reply.

The error is the same of this issue:

ERROR: Invalid interpolation format for "volumes" option in service "test": "${DATA_DIR-./test-results/worker}:/app/results"

When using a Dockerfile with a volume like this:

volumes:
    - ${DATA_DIR-./test-results/worker}:/app/results

Make sure your Compose file specified version 2.1 or higher

Thanks @shin- . It works! Sorry about wasting your time. I did not realize that the fix was not valid for older versions.

Was this page helpful?
0 / 5 - 0 ratings