简体   繁体   English

docker-compose:服务服务不支持的配置选项:'web'

[英]docker-compose : Unsupported config option for services service: 'web'

I am going through the Getting Started with Docker Compose page.我正在浏览Docker 撰写页面入门

In Step 3, I made a docker-compose.yml file as described:在第 3 步中,我制作了一个docker-compose.yml文件,如下所述:

version: '2'
services:
    web:
        build: .
        ports: 
            - "5000:5000"
        volumes: 
            - .:/code
        depends_on:
            - redis
    redis:
        image: redis

But when I run:但是当我运行时:

$ docker-compose up

I get following error:我收到以下错误:

Unsupported config option for services service: 'web'服务服务不支持的配置选项:'web'

What am I doing wrong?我究竟做错了什么? I was not able to figure out what is going on.我无法弄清楚发生了什么。

Support for the version 2 compose file format was introduced in docker-compose version 1.6 , released around February of this year. docker-compose version 1.6 中引入了对 version 2 compose 文件格式的支持,该版本于今年 2 月左右发布。

You're using 1.3.3, from July 2015.您使用的是 2015 年 7 月的 1.3.3。

You need to upgrade to a more recent version to use the version 2 format configuration files.您需要升级到更新的版本才能使用版本 2 格式的配置文件。

Since this is the first result on Googling "docker-compose Unsupported config option for services", I would like to add that the most common reason as of 2020 is missing of version: "3" .由于这是谷歌搜索“docker-compose Unsupported config option for services”的第一个结果,我想补充一点,截至 2020 年,最常见的原因是缺少version: "3"

Just add version: "3" to the start of your docker-compose.yml .只需将version: "3"添加到docker-compose.yml

From the docs :文档

There are currently three versions of the Compose file format:目前有三个版本的 Compose 文件格式:

  1. Version 1, the legacy format.版本 1,旧格式。 This is specified by omitting a version key at the root of the YAML.这是通过省略 YAML 根目录中的版本密钥来指定的。
  2. Version 2.x.版本 2.x。 This is specified with a version: '2' or version: '2.1', etc., entry at the root of the YAML.这是使用版本:'2' 或版本:'2.1' 等指定的,位于 YAML 的根目录。
  3. Version 3.x, the latest and recommended version, designed to be cross-compatible between Compose and the Docker Engine's swarm mode.版本 3.x,最新的和推荐的版本,旨在在 Compose 和 Docker Engine 的 swarm 模式之间交叉兼容。 This is specified with a version: '3' or version: '3.1', etc., entry at the root of the YAML.这通过版本:'3' 或版本:'3.1' 等指定,位于 YAML 的根目录。

In my case i had used a wrong indentation.就我而言,我使用了错误的缩进。 Recheck indentation of your docker-compose file to ensure it is correct重新检查docker-compose文件的缩进以确保它是正确的

I would recommend upgrading your docker-compose version, At the moment the safest way to upgrade docker-compose is by deleting it and reinstalling it.我建议升级您的 docker-compose 版本,目前升级 docker-compose 最安全的方法是删除并重新安装它。

rm /usr/local/bin/docker-compose

Reinstall:重新安装:

Update the apt package index, and install the latest version of Docker Compose:更新 apt package 索引,安装最新版 Docker 编写:

 sudo apt-get update

 sudo apt-get install docker-compose-plugin

Alternatively, to install a specific version of Compose CLI plugin:或者,要安装特定版本的 Compose CLI 插件:

a.一个。 List the versions available in your repo:列出您的存储库中可用的版本:

apt-cache madison docker-compose-plugin

b.湾。 From the list obtained use the version string you can in the second column to specify the version you wish to install.从获得的列表中,您可以使用第二列中的版本字符串来指定您希望安装的版本。 c. c。 Install the selected version:安装选定的版本:

sudo apt-get install docker-compose-plugin=<VERSION_STRING>

where <VERSION_STRING> is, for example,2.3.3~ubuntu-focal.其中 <VERSION_STRING> 是,例如,2.3.3~ubuntu-focal。

And verify that Docker Compose is installed correctly by checking the version.并通过检查版本来验证 Docker Compose 是否安装正确。

docker compose version

Added version: '3.1' at the top of my docker-compose.yml file and it worked添加版本:'3.1'在我的 docker-compose.yml 文件的顶部并且它有效

Check the indentation of your docker-compose file.检查 docker-compose 文件的缩进。

Try to open the file with Notepad++ (8.4.7 or a newer version).尝试使用 Notepad++(8.4.7 或更高版本)打开文件。 The whole file should show a green strip in the left.整个文件应该在左边显示一条绿色条带。 If it's orange or the green strip doesn't show for the entire file, it means the file is not valid an therefore not ready to go in your command line.如果它是橙色的或整个文件没有显示绿色条带,则表示该文件无效,因此尚未准备好在命令行中输入 go。

Hope it helps.希望能帮助到你。 It did in my case:)在我的情况下确实如此:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows中的docker-compose:服务的不受支持的配置选项:“ web” - docker-compose in windows: Unsupported config option for services: 'web' docker-compose:服务的配置选项不受支持:“redis” - docker-compose: Unsupported config option for services: 'redis' docker-compose:services.db 不支持的配置选项:“jupyter” - docker-compose: Unsupported config option for services.db: 'jupyter' docker-compose不支持的服务配置 - docker-compose unsupported config for services docker-compose:“运行时”不支持的配置选项 - docker-compose: Unsupported config option for 'runtime' 错误:撰写文件“./docker-compose.yml”服务的配置选项不受支持。web:“dockerfile” - ERROR: The Compose file './docker-compose.yml' Unsupported config option for services.web: 'dockerfile' Docker 为服务卷 mongodb 撰写不支持的配置选项 - Docker compose Unsupported config option for service volume mongodb 相当于docker-compose中的docker选项--config - equivalent of docker option --config in docker-compose 错误:撰写文件“.\docker-compose.yml”无效,因为:服务的配置选项不受支持。drupal:“postgres” - ERROR: The Compose file '.\docker-compose.yml' is invalid because: Unsupported config option for services.drupal: 'postgres' 错误:撰写文件“./docker-compose.yml”无效,因为:服务不支持的配置选项:“sqlite3” - ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services: 'sqlite3'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM