ERROR: yaml.scanner.ScannerError: while scanning a simple key
ERROR: yaml.scanner.ScannerError: while scanning a simple key;ERROR: The Compose file './docker-compose.yml' is invalid because:services.web1.ports contains an invalid type, it should be a number, or
·
在使用docker搭建漏洞靶场时,使用 vi docker-compose.yml 命令编辑完成其内容后执行 sudo docker-compose up -d命令以后台的方式运行容器时报错:
报错原因:vi docker-compose.yml文件内容中缩进和空格的位置不正确,应对其进行调整。
解决办法:把相应的地方进行缩进,如图
缩进前:
缩进后:
但是这里还有一个问题是,数字和“:”之间多了一个空格
直接运行会出现报错:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.web1.ports contains an invalid type, it should be a number, or an object
services.web1.ports contains an invalid type, it should be a number, or an object
services.web1.ports contains an invalid type, it should be a number, or an object
可能还会有如下报错:
sudo docker-compose up -d
ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType.
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.web1: '-"10000'
services.web1.ports contains an invalid type, it should be an array
这些都是空格的问题,把多余的空格删掉,有空格的位置补上,总之,你可以对比原docker-compose.yml文件和你输入的内容,将对应的空格对齐就好了。
错误解决了就可以正常执行命令了!
希望能对你有所帮助。
喜欢的话就点个赞吧!喜欢点赞的人运气都不会太差哦!
更多推荐
已为社区贡献1条内容
所有评论(0)