Я не могу отладить свой контейнер Docker в Visual Studio 2017.
Я использую Docker 18.06.1-ce и VS 15.8.8.
При запуске сеанса отладки в VS (control + F5) контейнер запускается нормально, но VS не подключен. Контейнер также продолжает работать, и не запущен в режиме dev
. Я должен использовать docker stop a76244870ffe
, если я хочу убить его.
Бег docker container ls
:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a76244870ffe myapplication "dotnet MyApplicat.." 25 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp dockercompose10819768170563966978_myapplicatio_1
докер-compose.yml:
version: '3.4'
services:
myapplication:
image: ${DOCKER_REGISTRY}myapplication
build:
context: .
dockerfile: dockerfile
ports:
- "80:80"
environment:
- ASPNETCORE_ENVIRONMENT=local
Построить вывод в VS:
1>------ Build started: Project: docker-compose, Configuration: Debug Any CPU ------
1>docker-compose -f "C:\mylocation\docker-compose.yml" -p dockercompose10819768170563966978 --no-ansi config
1>The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
1>services:
1> myapplication:
1> build:
1> context: C:\mylocation
1> dockerfile: dockerfile
1> environment:
1> ASPNETCORE_ENVIRONMENT: local
1> image: myapplication
1> ports:
1> - published: 80
1> target: 80
1>version: '3.4'
1>docker-compose -f "C:\mylocation\docker-compose.yml" -p dockercompose10819768170563966978 --no-ansi config
1>The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
1>services:
1> myapplication:
1> build:
1> context: C:\mylocation
1> dockerfile: dockerfile
1> environment:
1> ASPNETCORE_ENVIRONMENT: local
1> image: myapplication
1> ports:
1> - published: 80
1> target: 80
1>version: '3.4'
1>docker-compose -f "C:\mylocation\docker-compose.yml" -p dockercompose10819768170563966978 --no-ansi config
1>The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
1>services:
1> myapplication:
1> build:
1> context: C:\mylocation
1> dockerfile: dockerfile
1> environment:
1> ASPNETCORE_ENVIRONMENT: local
1> image: myapplication
1> ports:
1> - published: 80
1> target: 80
1>version: '3.4'
1>docker-compose -f "C:\mylocation\docker-compose.yml" -p dockercompose10819768170563966978 --no-ansi config
1>The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
1>services:
1> myapplication:
1> build:
1> context: C:\mylocation
1> dockerfile: dockerfile
1> environment:
1> ASPNETCORE_ENVIRONMENT: local
1> image: myapplication
1> ports:
1> - published: 80
1> target: 80
1>version: '3.4'
1>docker-compose -f "C:\mylocation\docker-compose.yml" -p dockercompose10819768170563966978 --no-ansi up -d
1>The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
1>Starting dockercompose10819768170563966978_myapplication_1 ...
1>Starting dockercompose10819768170563966978_myapplication_1 ... done
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
dockerfile:
FROM microsoft/dotnet:2.1-sdk AS builder
WORKDIR /app
COPY ./src/myapplication/myapplication.csproj ./src/myapplication/myapplication.csproj
COPY nuget.config ./
WORKDIR ./src/myapplication/
RUN dotnet restore
WORKDIR /app
COPY ./src ./src
WORKDIR ./src/myapplication/
RUN dotnet publish myapplication.csproj -c Release -o publish
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runner
WORKDIR /app
COPY --from=builder /app/src/myapplication/publish/ .
ENV ASPNETCORE_ENVIRONMENT local
EXPOSE 80
ENTRYPOINT ["dotnet", "MyApplication.dll"]