执行此命令时出错:

"docker-compose build && docker-compose up"

我试图将docker-compose文件中的版本号更改为3.3,但这也无效。

我的docker-compose文件如下所示“

version: '2.1'
control:
  build: ./env
  hostname: control
  links:
    - lb01
    - app01
    - app02
    - db01
  ports:
    - "2200:22"
  volumes:
    - ./:/work
lb01:
  build: ./env
  hostname: lb01
  links:
    - app01
    - app02
  ports:
    - "2201:22"
    - "8001:80"
app01:
  build: ./env
  hostname: app01
  links:
    - db01
  ports:
    - "2211:22"
    - "8081:80"
app02:
  build: ./env
  hostname: app02
  links:
    - db01
  ports:
    - "2212:22"
    - "8082:80"
db01:
  build: ./env
  hostname: db01
  ports:
    - "2222:22"
    - "3306:3306"

每当我运行above-mentioned命令时,我都会收到此错误:

ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Invalid top-level property "app01". Valid top-level sections for this Compose file are version, services, networks, volumes, and extensions starting with "x-".

You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") 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/
分析解答

见第2行:

version: '2.1'
services:
  control:
    build: ./env
    hostname: control
    links:
      - lb01
      - app01
      - app02
      - db01
    ports:
      - "2200:22"
    volumes:
      - ./:/work
  lb01:
    build: ./env
    hostname: lb01
    links:
      - app01
      - app02
    ports:
      - "2201:22"
      - "8001:80"
  app01:
    build: ./env
    hostname: app01
    links:
      - db01
    ports:
      - "2211:22"
      - "8081:80"
  app02:
    build: ./env
    hostname: app02
    links:
      - db01
    ports:
      - "2212:22"
      - "8082:80"
  db01:
    build: ./env
    hostname: db01
    ports:
      - "2222:22"
      - "3306:3306"