Dockertools: Error when starting container from VS2017

Created on 16 Oct 2017  路  3Comments  路  Source: microsoft/DockerTools

Hello,

I've recently started using the docker tools in Visual Studio 2017 15.4.

my docker-compose.yml looks like this:

version: '3'

services:
  testR_servicecore:
    image: testR_servicecore
    restart: always
    ports:
      - 32768:80
    build:
      context: .
      dockerfile: testrdf
    depends_on:
      - testR_postgre

  testR_postgre:
    image: postgres/latest
    restart: always
    build:
      context: .
      dockerfile: testPostgredf
    ports:
     - "5432:5432"
    environment:
      POSTGRES_USER: TestRPostgre
      POSTGRES_PASSWORD: Mortel
      POSTGRES_DB: TestR_db
    volumes:
       - pgdata:/var/lib/postgresql/data

volumes:
  pgdata:

While manually running docker-compose up runs fine, the issue is created by DockerTools itself.
The error generated by Visual Studio:

yaml.scanner.ScannerError: while scanning a simple key
  in "<omitted>\obj\Docker\docker-compose.vs.debug.g.yml", line 16, column 1
could not find expected ':'
  in "C:\<omitted>\obj\Docker\docker-compose.vs.debug.g.yml", line 17, column 15.

The generated docker-compose.vs.debug.g.yml, with the faulty line:

version: '3'

services:
  testR_postgre:
    image: postgres/latest:dev
    build:
      args:
        source: obj/Docker/empty/
    environment:
      - DOTNET_USE_POLLING_FILE_WATCHER=1
      - NUGET_FALLBACK_PACKAGES=$container_paths_to_fallback_packages_testR_postgre$
    volumes:
      - C:\_Dev\testR_ServiceCoreFull:/app
      - C:<omitted>\vsdbg:/remote_debugger:ro
      - $nuget_user_folder_testR_postgre$:/root/.nuget/packages:ro
$nuget_fallback_packages_volume_mapping_testR_postgre$
    entrypoint: tail -f /dev/null
    labels:
      com.microsoft.visualstudio.debuggee.program: "dotnet"
      com.microsoft.visualstudio.debuggee.arguments: " $debuggee_arguments_probing_paths_testR_postgre$ bin/Release/netcoreapp2.0/testR_ServiceCore.dll"
      com.microsoft.visualstudio.debuggee.workingdirectory: "/app"
      com.microsoft.visualstudio.debuggee.killprogram: "/bin/bash -c \"if PID=$$(pidof -x dotnet); then kill $$PID; fi\""

  testR_ServiceCore:
    image: testR_ServiceCore:dev
    build:
      args:
        source: obj/Docker/empty/
    environment:
      - DOTNET_USE_POLLING_FILE_WATCHER=1
      - NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages
    volumes:
      - C:\_Dev\testR_ServiceCoreFull:/app
      - C:<omitted>\vsdbg:/remote_debugger:ro
      - C:<omitted>\.nuget\packages\:/root/.nuget/packages:ro
      - C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages:ro

    entrypoint: tail -f /dev/null
    labels:
      com.microsoft.visualstudio.debuggee.program: "dotnet"
      com.microsoft.visualstudio.debuggee.arguments: " --additionalProbingPath /root/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages  bin/Release/netcoreapp2.0/testR_ServiceCore.dll"
      com.microsoft.visualstudio.debuggee.workingdirectory: "/app"
      com.microsoft.visualstudio.debuggee.killprogram: "/bin/bash -c \"if PID=$$(pidof -x dotnet); then kill $$PID; fi\""

In short:

according to the error the line:

$nuget_fallback_packages_volume_mapping_testR_postgre$

is causing the issue.
It resides in the docker-compose.vs.debug.g.yml, a file automatically generated by DockerTools.
The line is indented incorrectly and misses a -.

Solved by @sgreenmsft :
The dockerfile of the second container shouldn鈥檛 be placed in the same folder as the csproj鈥檚 dockerfile.

Most helpful comment

I'm also running into this and it's very very annoying. I have one job project and the job exe's arguments define the job to run, I want to have docker-compose reuse an image and fire up X instances as defined in my compose file

All 3 comments

Hi kdlslyv,

It turns out that defining an extra service and placing its dockerfile in the same folder as your csproj's dockerfile confuses the VS Docker tools. Sorry about that.

You can work around this by placing testR_postgre's Dockerfile in its own, separate folder.

Hey sgreenmsft,

Wow, thanks for that quick reply and an easy solution to work around that issue, I feared it鈥榙 be more complicated than that.

Awesome!

I'm also running into this and it's very very annoying. I have one job project and the job exe's arguments define the job to run, I want to have docker-compose reuse an image and fire up X instances as defined in my compose file

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tanaka-takayoshi picture tanaka-takayoshi  路  5Comments

hannesne picture hannesne  路  7Comments

eiximenis picture eiximenis  路  6Comments

Eilon picture Eilon  路  5Comments

kaicianflone picture kaicianflone  路  7Comments