以下是我的docker-compose.yml文件
version: “2”
services:
web:
build: .
environment:
MONGO_URI="mongodb://ravimongo:27017"
ports:
— “3000:3000”
links:
— ravimongo
depends_on:
— ravimongo
ravimongo:
image: mongo:3.2.6
ports:
— “27017:27017”
下面是错误信息:
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version ("2.0", "2.1", "3.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
docker-compose的版本信息:
docker-compose version 1.11.2, build dfed245
docker-py version: 2.1.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
docker版本信息:
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Tue Mar 28 00:40:02 2017
OS/Arch: darwin/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Fri Mar 24 00:00:50 2017
OS/Arch: linux/amd64
Experimental: true
我使用了 http://www.yamllint.com/ 和 https://codebeautify.org/yaml-validator验证这个yaml文件,没发现有什么问题。
YAML是有效的。不过你使用了一个左双引号,如:
version: “2”
基于错误显示,看来docker compose无法解析正确的版本。如果你使用了一个左双引号,而不是正常的双引号,docker compose将解析版本为“2”,而不是2。应该改为:
version: "2"