Docker: applications work fine with docker-layout, but how to run it through Visual Studio and debug it?

I have several projects, and they should work in separate containers, and I have a separate library, which also needs to be built. I found the following article on how to do this. I will show the docker file for only one project, because they are pretty much the same:

FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.0 AS builder
WORKDIR /src
COPY *.sln ./
COPY Web/Web.csproj Web/
RUN dotnet restore
COPY . .
WORKDIR /src/Web
RUN dotnet build -c Debug -o /app

FROM builder AS publish
RUN dotnet publish -c Debug -o /app

FROM base AS production
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Web.dll"]

So, as you can see, a multi-stage building is used. if i use docker-compose upthen everything works fine. Then I try to run it through Visual Studio, I see all the steps in the Outputwindow, but in the end I get the following error:

CoreCLR. , .NET Core. , .NET Core. '[13] dotnet' 145 (0x91). '' 145 (0x91).

? github repo.

PS. Tarun, , VS

FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Web.dll"]
+9
4

TL; DR;

, VS 2017 , . ,

docker-compose -f "C:\Users\tarlabs\Desktop\AspNetCoreMultiProject\docker-compose.yml" -f "C:\Users\tarlabs\Desktop\AspNetCoreMultiProject\docker-compose.override.yml" -f "C:\Users\tarlabs\Desktop\AspNetCoreMultiProject\obj\Docker\docker-compose.vs .debug.g.yml" -p dockercompose15184637154516733497 kill

-compose.override.yml

version: '3'

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

  api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "80"

.

-compose.vs .debug.g.yml

version: '3'

services:
  api:
    image: api:dev
    build:
      args:
        source: obj/Docker/empty/
    environment:
      - DOTNET_USE_POLLING_FILE_WATCHER=1
      - NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages
    volumes:
      - C:\Users\tarlabs\Desktop\AspNetCoreMultiProject:/app
      - C:\Users\tarlabs\vsdbg:/remote_debugger:ro
      - C:\Users\tarlabs\.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/Debug/netcoreapp2.0/Api.dll"
      com.microsoft.visualstudio.debuggee.workingdirectory: "/app"
      com.microsoft.visualstudio.debuggee.killprogram: "/bin/bash -c \"if PID=$$(pidof -x dotnet); then kill $$PID; fi\""

  web:
    image: web:dev
    build:
      args:
        source: obj/Docker/empty/
    environment:
      - DOTNET_USE_POLLING_FILE_WATCHER=1
      - NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages
    volumes:
      - C:\Users\tarlabs\Desktop\AspNetCoreMultiProject:/app
      - C:\Users\tarlabs\vsdbg:/remote_debugger:ro
      - C:\Users\tarlabs\.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/Debug/netcoreapp2.0/Web.dll"
      com.microsoft.visualstudio.debuggee.workingdirectory: "/app"
      com.microsoft.visualstudio.debuggee.killprogram: "/bin/bash -c \"if PID=$$(pidof -x dotnet); then kill $$PID; fi\""

  • ENTRYPOINT , VS tail -f /dev/null
  • com.microsoft.visualstudio.debuggee.arguments bin/Debug/netcoreapp2.0/Web.dll
  • /app com.microsoft.visualstudio.debuggee.workingdirectory
  • C:\Users\tarlabs\Desktop\AspNetCoreMultiProject:/app

Volume mount C:\Users\tarlabs\Desktop\AspNetCoreMultiProject:/app, Wow! , /app Docker, . , , , .

, Web.dll /app/Web/bin/Debug/netcoreapp2.0/Web.dll, , /app/bin/Debug/netcoreapp2.0/Web.dll. , .

. Docker, . , docker-compose.yml

version: '3'

services:
  webapplication1:
    image: webapplication1
    build:
      context: ./WebApplication1
      dockerfile:Dockerfile

  webapplication2:
    image: webapplication2
    build:
      context: ./../WebApplication2
      dockerfile: Dockerfile

, docker-compose.vs.debug.g.yml mount , docker-compose.yml. .

-compose.yml

version: '3'

services:
  web:
    image: web
    build:
      context: .
      dockerfile: Web/Dockerfile

  api:
    image:api
    build:
      context: .
      dockerfile: Api/Dockerfile

.,

- C:\Users\tarlabs\Desktop\AspNetCoreMultiProject:/app

, docker-compose.yml

version: '3'

services:
  web:
    image: web
    build:
      context: ./Web
      dockerfile: Dockerfile

  api:
    image:api
    build:
      context: ./Api
      dockerfile: Dockerfile

Dockerfile , VS . , 2 Dockerfile ,

FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app

, , . . , .

Debugging Works

+20

, .Net 2.0 App Linux. , . , csproj .

, . .NET- "WebApplication 1", , VS / , .

0

- (#) ( #... C:\Project\C#\MyProject\).

(C:\Project\C-sharp\MyProject\), .

0

.NET Core 3.0, docker-compose. , Dockerfiles docker-compose.yml MSDN, docker-compose PowerShell , , docker-compose Visual Studio .

, . ,

  1. Dockerfile .NET Core 3.0 SDK, Visual Studio

Docker 4.NET Core 3.0, .NET Core 5. 4.NET Core 4 5 Dockerfiles.

  1. Debug

(,....\bin), . Visual Studio /app , docker-compose.yml. , Docker.

TL; DR: docker-compose.yml docker-compose.override.yml

docker-compose:  - docker-compose.yml: , , , ,  - docker-compose.override.yml:  - docker-compose.ci-build.yml: Docker.

docker-compose.yml. Docker-compose.yml docker-compose.override.yml . Docker-compose.yml Docker-compose.ci-build.yml

, docker docker-compose.yml, docker-compose.override.yml. Visual Studio, , , docker-compose, docker-compose.yml docker-compose.override.yml. Visual Studio docker-compose .

docker-compose.yml docker-compose.override.yml Visual Studio docker-compose \obj\Docker: docker-compose.vs.debug.g.yml docker-compose.vs.debug.partial.g.yml. , .

  1. Paths in docker-compose and Dockerfile You should also be aware that changing the context in docker-compose.yml may require making changes to the Dockerfile project. Paths in the Dockerfile are contextual, not Dockerfile. Changing the context in docker-compose.yml may violate these relative paths.
0
source

All Articles