Docker Compose 文件无效,不允许附加属性 [英] Docker Compose file is invalid, additional properties not allowed
本文介绍了Docker Compose 文件无效,不允许附加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的示例 docker-compose.yml 文件.
This is my sample docker-compose.yml file.
version: '2'
config-server:
image: ccc/config-server
restart: always
registration-server:
image: ccc/registration-server
restart: always
ports:
- 1111:1111
当我使用 docker-compose up -d
时出现错误:
When I use docker-compose up -d
I get an error:
"ERROR: The Compose file './docker-compose.yml' is invalid because:
Additional properties are not allowed ('registration-server', 'config-server' were unexpected)
You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") 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/
推荐答案
你缺少一个 services
关键字,你正确的 .yml 是:
You are missing a services
keyword, your correct .yml is:
version: '2'
services:
config-server:
image: ccc/config-server
restart: always
registration-server:
image: ccc/registration-server
restart: always
ports:
- 1111:1111
这篇关于Docker Compose 文件无效,不允许附加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文