Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuild failing to parse a valid compose file #98

Closed
rbanks54 opened this issue Apr 25, 2018 · 17 comments
Closed

MSBuild failing to parse a valid compose file #98

rbanks54 opened this issue Apr 25, 2018 · 17 comments
Assignees
Labels

Comments

@rbanks54
Copy link

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.

@stevejgordon
Copy link

I'm seeing the same issue on 2.1.300-preview2-008530 on windows. and Visual Studio 2017 15.7 preview 4.

@pellea
Copy link

pellea commented May 2, 2018

Same error here with the latest VS2017 preview (15.7.0 preview 5).

@KevM
Copy link

KevM commented May 3, 2018

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"

@pellea
Copy link

pellea commented May 3, 2018

This notation isn't working for me. I already tested it and I got the same error.

@dbreshears
Copy link
Member

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?

@KevM
Copy link

KevM commented May 3, 2018

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}"

@haniamr
Copy link

haniamr commented May 3, 2018

@pellea one possible workaround you can try is to define those variables in docker-compose.override.yml instead and see if that works.

@pellea
Copy link

pellea commented May 4, 2018

My bad, the workaround works.

I didn't remove the '-' before the line of each env key/value.

@stevejgordon
Copy link

I can confirm that the workaround works for me too.

@pysco68
Copy link

pysco68 commented May 7, 2018

Same here, worked all fine until I installed VS 15.7.0 today. The notation from @KevM solved the issue.

@pitming
Copy link

pitming commented May 14, 2018

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

mjrousos added a commit to microsoft/dotnet-apiport that referenced this issue May 15, 2018
…specified in env var (#629)


* Add Dockerfiles to the gateway and configuration services
* Use more specific docker tags to avoid base images changing unexpectedly
* Add Service Fabric deployment manifests and script
* Don't use portability.dot.net as the default backend URI
  * For the time being, require the Portability Service URI to be specified explicitly, either with an environment variable or with a command line argument.
  * Once the new service backend is ready for general use, it can be the new
default.
* Replace DeploySF.bat with a more robust ps1 script
* Move SF manifests out of /src (and into /deploy)
* Use alternate docker-compose env var format to work around microsoft/DockerTools#98
* Add docker-compose targets
* Only require -e for commands that make remote calls
* Update apiport tests to include -e when necessary
mjrousos added a commit to microsoft/dotnet-apiport that referenced this issue May 18, 2018
* Add SF Mesh templates and deployment instructions
* Add an SF Mesh template with both Linux and Windows containers
* Use alternate docker-compose env var format to work around microsoft/DockerTools#98
@veuncent
Copy link

Note: don't forget to put a space between keys and values:
Yes:

    environment:
      ASPNETCORE_ENVIRONMENT: Development

No:

    environment:
      ASPNETCORE_ENVIRONMENT:Development

@DinnyMN
Copy link

DinnyMN commented May 31, 2018

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

@TroelsL
Copy link

TroelsL commented Jun 4, 2018

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
      - LETSENCRYPT_EMAIL=me@example.com

Changing to this fixed it:

    environment:
      VIRTUAL_HOST: devices.example.com
      LETSENCRYPT_HOST: devices.example.com
      LETSENCRYPT_EMAIL: me@example.com

@prisar
Copy link

prisar commented Aug 29, 2018

@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.

@haniamr
Copy link

haniamr commented Sep 12, 2018

@prisar thanks for the confirmation, I'll be closing this issue since the fix is already in the latest public version.

@haniamr haniamr closed this as completed Sep 12, 2018
@hammypants
Copy link

@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	

In docker-compose.yml

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests