“docker-compose.yml”无效,原因是:无效的顶级属性“wordpress”

epggiuax  于 2023-02-11  发布在  Docker
关注(0)|答案(1)|浏览(199)

运行docker-compose up时出现以下错误:

ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid top-level property "wordpress". 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/

基础架构详细信息:

  • 多克尔
Docker version 23.0.0, build e92dd87
  • docker-compose(使用apt-get install docker-compose安装)
docker-compose version 1.25.0, build unknown

docker-compose.yml

version: '3'

wordpress:
  image: wordpress
  links:
    - db:mysql

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: '<a secure password>'
aiazj4mn

aiazj4mn1#

在顶层,你应该有services,然后才是服务本身。

version: '3'

services:
  wordpress:
    image: wordpress
    links:
      - db:mysql

  db:
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: '<a secure password>'

相关问题