Docker Compose 中的无效类型错误
Invalid type error in Docker Compose
我在 Docker Compose 中遇到错误。撰写文件是
version: '2'
services:
api:
build:
context: .
dockerfile: webapi/dockerfile
ports:
- 210
web:
build:
context: .
dockerfile: app/dockerfile
ports:
- 80
lbapi:
image: dockercloud/haproxy
links:
– api
ports:
– 8080:210
lbweb:
image: dockercloud/haproxy
links:
– web
ports:
– 80:80
运行docker-compose up
时的错误是:
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
services.lbapi.ports contains an invalid type, it should be an array
services.lbweb.ports contains an invalid type, it should be an array
services.lbapi.links contains an invalid type, it should be an array
services.lbweb.links contains an invalid type, it should be an array
请帮忙。
- docker-compose version 1.8.0-rc1, build 9bf6bc6
- docker-py版本:1.8.1
- CPython 版本:2.7.11
- OpenSSL 版本:OpenSSL 1.0.2d 2015 年 7 月 9 日
您是否尝试在端口上使用引号?
version: '2'
services:
api:
build:
context: .
dockerfile: webapi/dockerfile
ports:
- 210
web:
build:
context: .
dockerfile: app/dockerfile
ports:
- 80
lbapi:
image: dockercloud/haproxy
links:
– api
ports:
– "8080:210"
lbweb:
image: dockercloud/haproxy
links:
– web
ports:
– "80:80"
你应该用引号(“8080:210”)将端口括起来,因为 docker-compose expecting string or number in "ports" array 但 8080:210 实际上不是它们中的任何一个.参见 https://docs.docker.com/compose/compose-file/#ports
对于最终到达此页面的任何人 - 因为它目前是 google 上的热门搜索结果 - 请检查你的语法。多是因为少了缩进,双引号,少了space,等等
有关正确语法示例的参考,请查看 docker 中的文档:https://docs.docker.com/compose/compose-file/
docker compose 期望端口为数组格式,为此您需要用大括号覆盖某些参数。
例如:
...
ports: ["8080:8080"]
...
此外,请确保从网络或其他来源复制时,正确格式化引号并应用它。
我在 Docker Compose 中遇到错误。撰写文件是
version: '2'
services:
api:
build:
context: .
dockerfile: webapi/dockerfile
ports:
- 210
web:
build:
context: .
dockerfile: app/dockerfile
ports:
- 80
lbapi:
image: dockercloud/haproxy
links:
– api
ports:
– 8080:210
lbweb:
image: dockercloud/haproxy
links:
– web
ports:
– 80:80
运行docker-compose up
时的错误是:
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
services.lbapi.ports contains an invalid type, it should be an array
services.lbweb.ports contains an invalid type, it should be an array
services.lbapi.links contains an invalid type, it should be an array
services.lbweb.links contains an invalid type, it should be an array
请帮忙。
- docker-compose version 1.8.0-rc1, build 9bf6bc6
- docker-py版本:1.8.1
- CPython 版本:2.7.11
- OpenSSL 版本:OpenSSL 1.0.2d 2015 年 7 月 9 日
您是否尝试在端口上使用引号?
version: '2'
services:
api:
build:
context: .
dockerfile: webapi/dockerfile
ports:
- 210
web:
build:
context: .
dockerfile: app/dockerfile
ports:
- 80
lbapi:
image: dockercloud/haproxy
links:
– api
ports:
– "8080:210"
lbweb:
image: dockercloud/haproxy
links:
– web
ports:
– "80:80"
你应该用引号(“8080:210”)将端口括起来,因为 docker-compose expecting string or number in "ports" array 但 8080:210 实际上不是它们中的任何一个.参见 https://docs.docker.com/compose/compose-file/#ports
对于最终到达此页面的任何人 - 因为它目前是 google 上的热门搜索结果 - 请检查你的语法。多是因为少了缩进,双引号,少了space,等等
有关正确语法示例的参考,请查看 docker 中的文档:https://docs.docker.com/compose/compose-file/
docker compose 期望端口为数组格式,为此您需要用大括号覆盖某些参数。 例如:
...
ports: ["8080:8080"]
...
此外,请确保从网络或其他来源复制时,正确格式化引号并应用它。