Upon conversion from the short syntax of volume mounting to the long syntax, paths including environment variables in the source definition of the volume directory are no more properly parsed.
Here is the sample of volume mounting instruction with long syntax:
volumes:
- type: bind
source: $HOME/app/docker-app/db-data
target: /data/db
bind:
propagate: rshared
The resulting error is:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.app.volumes contains an invalid type, it should be a string
Here is the prior short syntax that did not raise any errors:
volumes:
- $HOME/app/docker-app/db-data:/data/db
Both of the instructions are issued for version: "2"
of docker-compose, but the issue remains in version: "3"
.
Output of docker-compose version
docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
Output of docker version
Client:
Version: 17.03.0-ce
API version: 1.26
Go version: go1.7.5
Git commit: 3a232c8
Built: Tue Feb 28 07:57:58 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.0-ce
API version: 1.26 (minimum version 1.12)
Go version: go1.7.5
Git commit: 3a232c8
Built: Tue Feb 28 07:57:58 2017
OS/Arch: linux/amd64
Experimental: false
Output of docker-compose config
(Make sure to add the relevant -f
and other flags)
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.app.volumes contains an invalid type, it should be a string
volumes:
- type: bind
source: $HOME/app/docker-app/db-data
target: /data/db
bind:
propagate: rshared
docker-compose build
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.app.volumes contains an invalid type, it should be a string
Proper volume mapping, consistent with short syntax
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.app.volumes contains an invalid type, it should be a string
Ubuntu 14.04 LTS 64 Bit, docker-compose
installed and updated with apt-get
Closed: issue was due to the wrong version of docker-compose
declared at the beginning of the docker-compose.yml
In case this helps anyone else, an example of a correct version to use would be "3.7", see e.g. here: https://docs.docker.com/compose/compose-file/#long-syntax-3
"3" is insufficient.
Most helpful comment
In case this helps anyone else, an example of a correct version to use would be "3.7", see e.g. here: https://docs.docker.com/compose/compose-file/#long-syntax-3
"3" is insufficient.