gpt4 book ai didi

docker 撰写 : Unsupported config option for services service: 'web'

转载 作者:IT老高 更新时间:2023-10-28 12:35:33 25 4
gpt4 key购买 nike

我正在查看 Getting Started with Docker Compose页面。

在第 3 步中,我制作了一个 docker-compose.yml 文件,如下所述:

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

但是当我运行时:

$ docker-compose up

我收到以下错误:

Unsupported config option for services service: 'web'

我做错了什么?我无法弄清楚发生了什么。

最佳答案

由于这是谷歌搜索“docker-compose Unsupported config option for services”的第一个结果,我想补充一点,截至 2020 年,最常见的原因是缺少 version: "3" .

只需将 version: "3" 添加到 docker-compose.yml 的开头即可。

来自 docs :

There are currently three versions of the Compose file format:

  1. Version 1, the legacy format. This is specified by omitting a version key at the root of the YAML.
  2. Version 2.x. This is specified with a version: '2' or version: '2.1', etc., entry at the root of the YAML.
  3. Version 3.x, the latest and recommended version, designed to be cross-compatible between Compose and the Docker Engine’s swarm mode. This is specified with a version: '3' or version: '3.1', etc., entry at the root of the YAML.

关于 docker 撰写 : Unsupported config option for services service: 'web' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36724948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com