【发布时间】:2019-07-23 04:16:44
【问题描述】:
我有 .net 核心项目 (MySolution.Web.API),它引用了几个 .net 标准 2.0 项目
(MySolution.Infrastructure 和 MySolution.Domain)
我的硬盘解决方案是这样的
.vs/
bin/
packages/
MySolution.Infrastructure/
MySolution.Domain/
MySolution.Web.API/
.dockerignore
docker-compose.yml
....
MySolution.sln
在 MySolution.Web.API 里面有 Dockerfile
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY MySolution.Web.API.csproj Web.API/
COPY MySolution.Infrastructure.csproj MySolution.Infrastructure/
COPY MySolution.Domain.csproj MySolution.Domain/
RUN dotnet restore MySolution.Web.API.csproj
COPY . .
WORKDIR /src/MySolution.Web.API
RUN dotnet build MySolution.Web.API.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish MySolution.Web.API.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MySolution.Web.API.dll"]
当我尝试使用
创建图像时docker build -t mysolution.web.api .
Step 1/20 : FROM microsoft/aspnetcore:2.0 AS base
---> db030c19e94b
Step 2/20 : WORKDIR /app
---> Using cache
---> c46d1d16c23c
Step 3/20 : EXPOSE 80
---> Using cache
---> 615befacb30c
Step 4/20 : FROM microsoft/aspnetcore-build:2.0 AS build
---> 06a6525397c2
Step 5/20 : WORKDIR /src
---> Using cache
---> d8b8d0f73449
Step 6/20 : COPY MySolution.Web.API.csproj MySolution.Web.API/
---> Using cache
---> bcfb36743124
Step 7/20 : COPY MySolution.Infrastructure.csproj MySolution.Infrastructure/
COPY failed: stat /var/lib/docker/tmp/docker-builder805773291/MySolution.Infrastructure.csproj: no such file or directory
由于 Dockerfile 在 MySolution.Web.API/ 文件夹中,我尝试将 Dockerfile 中复制命令的路径更改为
COPY ../MySolution.Infrastructure.csproj ../MySolution.Infrastructure/
但我不允许这样做。
【问题讨论】: