Dockerfile如下:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
//这一行copy是没有问题的,由于执行docker build的目录就是在项目根目录下
COPY ["Api.Admin.csproj", "Api.Admin/"]
//下面的4个类库项目,是api.admin项目依赖的项目(因为没有依赖nuget包,直接从本地项目引用)
COPY ["../lib-common/Api.Common/Api.Common.csproj", "../lib-common/Api.Common/"]
COPY ["../lib-common/Api.Common1/Api.Common1.csproj", "../lib-common/Api.Common1/"]
COPY ["../lib-common/Api.Common2/Api.Common2.csproj", "../lib-common/Api.Common2/"]
COPY ["../lib-common/Api.Common3/Api.Common3.csproj", "../lib-common3/Api.Common3/"]
RUN dotnet restore "Api.Admin/Api.Admin.csproj"
COPY . .
WORKDIR "/src/Api.Admin"
RUN dotnet build "Api.Admin.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Api.Admin.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Api.Admin.dll"]
cmd定位到api.admin项目目录下,执行docker build 命令,会提示定位到
COPY ["../lib-common/Api.Common/Api.Common.csproj", "../lib-common/Api.Common/"]
这一行错误,COPY failed: Forbidden path outside the build context:
- run neo4j with docker-compose - neo4j not accessib
- Composer install with dockerfile
- How to use custom Nginx config for official nginx
- Docker Compose: How to specify path to docker file
- Docker build image - glob error { Error: EPERM: op
- .netCore 控制台程序输出配置问题
- .NetCore Host.CreateDefaultBuilder 源码
- vs2019 docker打包.netcore
- netcore3.1 WebApi独立运行跨域设置无效
- Building Dockerfile fails when touching a file aft
- Import Data on MongoDB using Docker-Compose
- “docker build” requires exactly 1 argument(s)
- Gitlab CI / Docker: Use custom image for job
直接copy 所有的项目吧简单粗暴
这是我的源码示例
https://github.com/zhaozhengyan/WebNotebook
将 Dockerfile 放到上级目录