我的dotnet core 2.2应用程序具有以下结构(非常标准):
- .sln
- DockerFile
- MyApp/
|- *.csproj
我的DockerFile是这样的:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY ./MyApp/*.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "MyApp.dll"]
我总是会收到此错误:
Step 9/10 : COPY --from=build-env /app/out .
ERROR: Service 'myapp' failed to build: COPY failed: stat /var/lib/docker/overlay2/ed30d6e8a88b5d65bb14a5e972428135a78701c860f510d4dcc3e5c4947916d3/merged/app/out: no such file or directory
我上网查看,只能找到有关重置Docker数据的建议,但我尝试没有成功。
我正在使用docker build .
存储库中的命令DockerFile
进行构建。
我的DockerFile是否缺少某些内容?您有什么线索可以帮助我解决这个问题吗?
答案 0 :(得分:0)
我有类似的dockerfile。但我的输出是/out
并从/out
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY ./MyApp/*.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o /out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY --from=build-env /out .
ENTRYPOINT ["dotnet", "MyApp.dll"]