简体   繁体   中英

Visual Studio 2017 Docker project on Windows volumes issue

I am checking a new Visual Studio 2017 with built in connectivity to Docker. Once done all things installed and solved a number of issues on establishing connection between Visual Studio and Docker running in VirtualBox VM i am facing and issue when VS is unable to run container due to volumes mapping. Having read a number of posts for similar issues, i still cant run it..

Its fully default .NET core sample-template app from VS 2017 with Docker support.

docker-compose.ci.build.yml

version: '2'

services:
  ci-build:
    image: microsoft/aspnetcore-build:1.0-1.1
    volumes:
      - .:/src
    working_dir: /src
    command: /bin/bash -c "dotnet restore ./WebApplication1.sln && dotnet publish ./WebApplication1.sln -c Release -o ./obj/Docker/publish"

docker-compose.yml

version: '2'

services:
  webapplication1:
    image: webapplication1
    environment:
    - COMPOSE_CONVERT_WINDOWS_PATHS=1
    build:
      context: ./WebApplication1
      dockerfile: Dockerfile

docker-compose.override.yml

version: '2'

services:
  webapplication1:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development      
    ports:
      - "80"

docker-compose.vs.debug.yml

version: '2'

services:
  webapplication1:
    image: webapplication1:dev
    build:
      args:
        source: ${DOCKER_BUILD_SOURCE}
    environment:
      - DOTNET_USE_POLLING_FILE_WATCHER=1    
    volumes:
      - ./WebApplication1:/app
      - ~/.nuget/packages:/root/.nuget/packages:ro
      - ~/clrdbg:/clrdbg:ro
    entrypoint: tail -f /dev/null
    labels:
      - "com.microsoft.visualstudio.targetoperatingsystem=linux"

Dockerfile

FROM microsoft/aspnetcore:1.1
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "WebApplication1.dll"]

Error:

ERROR: for webapplication1 Cannot create container for service webapplication1: invalid bind mount spec "C:\\Users\\UserName\\Documents\\Visual Studio 2017\\Projects\\WebApplication1\\WebApplication1:/app:rw": invalid volume specification: 'C:\\Users\\UserNameDocuments\\Visual Studio 2017\\Projects\\WebApplication1\\WebApplication1:/app:rw'

Where the problem is? I tried escaping slashes and on and off COMPOSE_CONVERT_WINDOWS_PATHS, but result is all the time same. Please help out!

I believe this is due to running the latest version of Docker Toolbox which isn't passing through the DOCKER_BUILD_SOURCE environment variable. I don't believe Docker Toolbox is planning to resolve this on their end since they are treating environment variables as they should; but visual studio will need an update or the default docker compose templates will need an update to handle this.

I also fought with this for a few hours and continued to struggle wondering why something like this didn't work...

volume: - c:\\[dir]:c:\\[dir]

turns out it is picky about case on the drive and this ultimately worked:

volume: - C:\\[dir]:C:\\[dir]

Maybe related to missing shared drive in Docker?

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM