过去几周,我一直在开发一个在 Visual Studio 2019 中使用 C# .NET Core 构建的项目。我启用了 Docker 支持并使用 docker-compose 来启动 2 个容器(它启动了一个 identityserver4 和 webapi)。我已经为两个项目创建了 dockerfiles,并创建了一个用于启动服务堆栈的 docker-compose 文件。
我遇到的问题是,当我在 Visual Studio 调试模式下运行 docker-compose 时,它似乎没有运行我的 Dockerfile。在 Dockerfile 的最后一步中,我复制了一些文件并执行命令。这些不会运行。但是,当我docker build在命令行中使用时,它确实会执行那些 Dockerfile 命令。
附上我的 2 个 docker 文件和 docker compose。
Web API Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["Api/MyApp.Api.Core/MyApp.Api.Core.csproj", "Api/MyApp.Api.Core/"]
COPY ["Api/MyApp.Api.Base/MyApp.Api.Base.csproj", "Api/MyApp.Api.Base/"]
COPY ["Base/MyApp.Base.Contracts/MyApp.Base.Contracts.csproj", "Base/MyApp.Base.Contracts/"]
COPY ["Base/MyApp.Base.Model/MyApp.Base.Model.csproj", "Base/MyApp.Base.Model/"]
COPY ["Data/MyApp.Data.EntityFramework/MyApp.Data.EntityFramework.csproj", "Data/MyApp.Data.EntityFramework/"]
COPY ["ContactpersoonService.cs/MyApp.Services.csproj", "ContactpersoonService.cs/"]
COPY ["Apps/MyApp.Apps.Settings/MyApp.Apps.Settings.csproj", "Apps/MyApp.Apps.Settings/"] …Run Code Online (Sandbox Code Playgroud)