在SO上也提出了相同的问题,他们都有答案是缩进或编码。
我尝试在http://yaml-online-parser.appspot.com/解析我的YML,它解析得很好。
version: '3'
services:
api:
image: testdocker/api
container_name: testdocker_api
build:
context: .
ports:
- 5000:80
environment:
ASPNETCORE_ENVIRONMENT: Production
不知道为什么在做docker-compose时出现此错误
Docker version 18.03.0-ce, build 0520e24
最佳答案
这可能对在Visual Studio 2017中创建docker-compose文件的所有.NET开发人员有所帮助。
Creating docker-compose file in Visual Studio 2017 was the issue.
解决步骤:
- I used Notepadd++ and this time created a YAML file as template.
- Create you YML configuration.
- Copy to your project directory.
- Run
docker-compose
up
这帮助我解决了问题。
关于docker - 在文件 '.\docker-compose.yml'中,服务 'version'必须是映射而不是字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49818588/