如何修复docker compose文件中的错误

如何修复docker compose文件中的错误,docker,docker-compose,dockerfile,Docker,Docker Compose,Dockerfile,我的docker compose文件中有一些代码。示例如下: version: '3.4' services: api.gw: image: ocelotapigw build: context: . dockerfile: src/OcelotApiGw/Dockerfile catalog.api: image: catalogapi build: context: . dockerfi

我的docker compose文件中有一些代码。示例如下:

version: '3.4'

services:

  api.gw:
    image: ocelotapigw
    build:
      context: .
      dockerfile: src/OcelotApiGw/Dockerfile

  catalog.api:
    image: catalogapi
      build:
        context: .
        dockerfile: src/Services/Catalog.Api/Dockerfile

      depends_on:
        - api.gw

  identity.api:
    image: identityapi
      build:
        context: .
        dockerfile: src/Services/Identity.Api/Dockerfile

      depends_on:
        - api.gw

  eshop:
    image: eshop
    build:
      context: .
      dockerfile: src/eShop/Dockerfile

    depends_on:
      - api.gw
但当“docker compose up”命令启动时,我收到一个错误: -码头工人整理 错误:yaml.scanner.ScannerError:此处不允许映射值 在“\docker compose.yml”第13行第12列中


请帮忙。告诉我发生的原因。

docker compose.yaml文件的语法错误

试试这个

version: '3.4'

services:

  api.gw:
    image: ocelotapigw
    build:
      context: .
      dockerfile: src/OcelotApiGw/Dockerfile

  catalog.api:
    image: catalogapi
    build:
      context: .
      dockerfile: src/Services/Catalog.Api/Dockerfile

    depends_on:
      - api.gw

  identity.api:
    image: identityapi
    build:
      context: .
      dockerfile: src/Services/Identity.Api/Dockerfile

    depends_on:
      - api.gw

  eshop:
    image: eshop
    build:
      context: .
      dockerfile: src/eShop/Dockerfile

    depends_on:
      - api.gw
注意:
构建
图像
依赖
字段应正确对齐

要验证docker compose.yaml的语法,请使用命令

docker-compose -f docker-compose.yaml config