我正在使用我创建的本地docker映像。
现在我正在使用docker-compose发送更多参数。
version: '2'
services:
helloworld:
image: helloworld:1.0
environment:
ports:
- "8002:8002"
因此,根据docker文档https://docs.docker.com/compose/compose-file/compose-file-v2/#ports是正确的方法
但是每次我尝试运行它,我都会得到
services.helloworld.enviroment.ports contains ["8002"], which is an invalid type, it should be a string, number, or a null
我尝试删除引号-,不同的空格,所有的结果都相同::s应该很简单,但无法弄清楚,有什么主意吗?
答案 0 :(得分:2)
Yaml文件对空格敏感。通过缩进,您已将端口放置在不属于该端口的环境部分中。相反,您需要在服务中使用它:
version: '2'
services:
helloworld:
image: helloworld:1.0
ports:
- "8002:8002"