撰写文件版本错误

时间:2018-12-04 12:24:30

标签: docker docker-compose

我从https://store.docker.com/editions/community/docker-ce-desktop-windows

安装了Docker。

我下载了一些资源以与docker一起运行并运行docker-compose up

不幸的是,我看到了:

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
docker-compose version 1.11.1, build 7afaa436
docker-py version: 2.0.2
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

我没有使用Docker的经验,但是我怀疑这里存在版本问题。但是我不知道如何升级docker-compose。我对吗?我该怎么办?

更新: docker-compose.yml就是这样

version: '3.4'

services:
    php:

2 个答案:

答案 0 :(得分:2)

*。yml文件的版本“ 3.1”之前都支持您的docker-compose version 1.11.1。 (您的配置是3.4)

将您的docker-compose更新到最新的(1.23.2)版本,以便能够运行最高为“ 3.7”的撰写文件

https://docs.docker.com/compose/install/#install-compose

答案 1 :(得分:1)

您的文件docker-compose.yml出错。您应该声明一个有效的版本,然后将所有内容置于服务下,例如:

version: '3'
service:
  service1:
    # ...
  service2:
    # ...

或忽略版本并将所有服务放在根目录中:

service1:
  # ...
service2:
  # ...