我在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运行时的错误
是:
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版本1.8.0-rc1,内部版本9bf6bc6
docker-py版本: 1.8.1
CPython版本: 2.7.11
OpenSSL版本: OpenSSL 1.0.2d 2015年7月9日
发布于 2016-06-22 14:55:33
你有没有试过:
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"发布于 2020-03-21 17:19:31
对于任何最终出现在这个页面上的人来说--目前它是google上最热门的搜索结果--
请检查您的语法
..。这主要是因为缺少缩进、双引号、缺少空格等。
有关正确语法示例的参考,请查看docker提供的文档:
https://docs.docker.com/compose/compose-file/
发布于 2016-06-22 15:00:30
您应该用括号覆盖端口,因为docker-compose需要" ports“数组中的字符串或数字,但8080:210不是数字。请参见
https://docs.docker.com/compose/compose-file/#ports
https://stackoverflow.com/questions/37960226
复制相似问题