When I try to build a .dcproj I've recently started seeing this error:
1>------ Build started: Project: docker-compose, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(294,5): error : (Line: 10, Col: 7, Idx: 156) - (Line: 10, Col: 7, Idx: 156): Expected 'MappingStart', got 'SequenceStart' (at Line: 10, Col: 7, Idx: 156).
1>Done building project "docker-compose.dcproj" -- FAILED.
The top part of the dockerfile is as follows:
version: '3.6'
services:
mssql:
image: microsoft/mssql-server-linux:2017-latest
hostname: mssql
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${SA_Password}
Where the first element of the environment section is causing the problem.
The docker-compose.yml file is perfectly fine and everything works as expected using docker-compose up
P.S. I did recently install the latest 2.1.300-preview2-008533 dotnet core SDK, but I haven't uninstalled it yet to see if it is somehow causing the problem.
I'm seeing the same issue on 2.1.300-preview2-008530 on windows. and Visual Studio 2017 15.7 preview 4.
Same error here with the latest VS2017 preview (15.7.0 preview 5).
I too had this problem. I was able to work around it by using the alternative environment notation:
rabbitmq:
image: "rabbitmq:3.6-management-alpine"
platform: linux
environment:
RABBITMQ_ERLANG_COOKIE: "weeeeeeeeeeeeeeee"
RABBITMQ_DEFAULT_USER: "rabbitmq"
RABBITMQ_DEFAULT_PASS: "Password123!"
RABBITMQ_DEFAULT_VHOST: "/"
ports:
- "15672:15672"
- "5672:5672"
This notation isn't working for me. I already tested it and I got the same error.
Thanks for reporting. We are investigating the parsing issue in our tooling. I did find the alternative environment notation seemed to work as a workaround. @pellea, what is the error you see with the workaround?
Try the following. This works for me. I think the underscores are causing the problem.
mssql:
image: microsoft/mssql-server-linux:2017-latest
platform: linux
environment:
"ACCEPT_EULA": "Y"
"SA_PASSWORD": "${SA_Password}"
@pellea one possible workaround you can try is to define those variables in docker-compose.override.yml instead and see if that works.
My bad, the workaround works.
I didn't remove the '-' before the line of each env key/value.
I can confirm that the workaround works for me too.
Same here, worked all fine until I installed VS 15.7.0 today. The notation from @KevM solved the issue.
Same problem here with 15.7.1.
Actually my docker-compose file is still in version 2 can that be the problem ?
will try the workaround
Note: don't forget to put a space between keys and values:
Yes:
environment:
ASPNETCORE_ENVIRONMENT: Development
No:
environment:
ASPNETCORE_ENVIRONMENT:Development
Running into this same issue but I am unsure how to convert nested variables into the working format.
environment:
- Mongo:Host=mongo
- Mongo:Port=27017
Update: this worked after finding the right docs here
environment:
Mongo__Host: mongo
Mongo__Port: 27017
Also ran into this issue after VS2017 automatically updated my project. This worked before:
environment:
- VIRTUAL_HOST=devices.example.com
- LETSENCRYPT_HOST=devices.example.com
- [email protected]
Changing to this fixed it:
environment:
VIRTUAL_HOST: devices.example.com
LETSENCRYPT_HOST: devices.example.com
LETSENCRYPT_EMAIL: [email protected]
@haniamr removing
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
from docker-compose.yml worked for me. I kept it in docker-compose.override.yml also.
@prisar thanks for the confirmation, I'll be closing this issue since the fix is already in the latest public version.
@haniamr This is an issue in VS 15.9.6 when using the same valid format for build arguments.
Build:
4>------ Build started: Project: docker-compose, Configuration: Debug Any CPU ------
4>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(291,5): error : (Line: 11, Col: 9, Idx: 171) - (Line: 11, Col: 9, Idx: 171): Expected 'MappingStart', got 'SequenceStart' (at Line: 11, Col: 9, Idx: 171).
4>Done building project "docker-compose.dcproj" -- FAILED.
Severity Code Description Project File Line Suppression State
Error (Line: 11, Col: 9, Idx: 171) - (Line: 11, Col: 9, Idx: 171): Expected 'MappingStart', got 'SequenceStart' (at Line: 11, Col: 9, Idx: 171). docker-compose C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 291
md5-b8091e2986a0ec4858d9463efafe2431
services:
web:
image: web
build:
context: ./backend/src
dockerfile: Web/Dockerfile
target: final
args:
- BUILD_CONFIGURATION=Debug
The args part of the file does not support said format. I would expect to be able to use it.
Should I make this a new issue?
Most helpful comment
I too had this problem. I was able to work around it by using the alternative environment notation: