简体   繁体   English

错误:撰写文件 docker-compose.yml 无效

[英]ERROR: The Compose file docker-compose.yml is invalid

version: '3.7'
services:
  docker-mongo:
   image:
     - mongo:4.2.1
   ports:
     - "27017:27017"
   networks:
     - mynetwork


networks:
  mynetwork:

When I execute docker-compose config I got the following error:当我执行docker-compose config ,出现以下错误:

Version in "./docker-compose.yml" is unsupported. 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/

So according to the error message I tried with version 2.2 and 3.3 both results in the same error message因此,根据我尝试使用2.23.3版的错误消息,两者都导致相同的错误消息

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.docker-mongo.image contains an invalid type, it should be a string
  • Ubuntu 18.04.2 LTS Ubuntu 18.04.2 LTS
  • Docker version 18.09.6, build 481bc77 Docker 版本 18.09.6,构建 481bc77
  • docker-compose version 1.17.1, build unknown docker-compose 版本 1.17.1,构建未知

the error message is self explain, your docker-compose should be like below:错误消息是自我解释的,您的 docker-compose 应如下所示:

version: '3.7'
services:
  docker-mongo:
   image: mongo:4.2.1
   ports:
     - "27017:27017"
   networks:
     - mynetwork


networks:
  mynetwork:

暂无
暂无

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

相关问题 错误:撰写文件“./docker-compose.yml”无效,因为:services.mysql.ports 无效 - ERROR: The Compose file './docker-compose.yml' is invalid because: services.mysql.ports is invalid 错误:撰写文件“./docker-compose.yml”无效,因为:services.jenkins.networks 包含无效类型 - ERROR: The Compose file './docker-compose.yml' is invalid because: services.jenkins.networks contains an invalid type 错误:撰写文件“.\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' 错误:Compose 文件“./docker-compose.yml”无效,因为:services.jenkins.volumes 包含无效类型,它应该是一个数组 - ERROR: The Compose file './docker-compose.yml' is invalid because: services.jenkins.volumes contains an invalid type, it should be an array 运行撰写yml文件docker-compose.yml的Docker堆栈部署命令错误 - Docker stack deploy command error running compose yml file docker-compose.yml 错误:在文件“ ./docker-compose.yml”中,卷必须是映射,而不是数组 - ERROR: In file './docker-compose.yml', volume must be a mapping, not an array 获取错误为 ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services: 'db' while compose - Getting the error as ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services: 'db' while composing 我在 docker-compose.yml 文件中遇到错误 - I am getting error in docker-compose.yml file 错误:在文件 './docker-compose.yml' 中,服务必须是映射,而不是 NoneType - ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM