gpt4 book ai didi

docker - dotnet core 2.2应用程序DockerFile COPY失败/over2/

转载 作者:行者123 更新时间:2023-12-02 19:53:26 24 4
gpt4 key购买 nike

我的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是否缺少某些内容?您有什么线索可以帮助我解决吗?

最佳答案

我有类似的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"]

关于docker - dotnet core 2.2应用程序DockerFile COPY失败/over2/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59242982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com