我在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
请帮忙。
答案 0 :(得分:9)
你有没有尝试过:
SELECT c.Name,
MAX(CASE WHEN step = 'A' THEN created END) AS A_date,
MAX(CASE WHEN step = 'B' THEN created END) AS B_date
FROM customer c
JOIN steps s ON c.Id = s.FK_customer
GROUP BY c.Name
答案 1 :(得分:2)
你应该用括号覆盖端口,因为docker-compose期待字符串或数字在" ports"数组,但8080:210不是数字。见https://docs.docker.com/compose/compose-file/#ports
答案 2 :(得分:2)
对于最终进入此页面的任何人-目前它是Google上搜索量最高的结果-请检查您的语法。主要原因是缺少缩进,双引号,空格等。
有关正确语法示例的参考,请查阅docker上的文档:https://docs.docker.com/compose/compose-file/
答案 3 :(得分:2)
docker compose 期望端口为数组格式,为此您需要用大括号覆盖某些参数。 例如:
...
ports: ["8080:8080"]
...
此外,请确保在从网络或其他来源复制时,正确格式化并应用引号。