我正在尝试使用这个Docker构造:
可选择通过添加AS名称将名称赋予新的构建阶段 到FROM指令。该名称可用于后续的FROM和 COPY --from =指示内置图像的指令 这个阶段。
但是我收到了这条消息:
COPY failed: stat /var/lib/docker/tmp/docker-builder869050639/-–from=build-env:
no such file or directory
是否在Docker for Windows 17.09.0-ce-win33(13620)上支持从前一阶段复制文件?这是Dockerfile:
FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app
COPY ./ ./
RUN dotnet build ProviderApi.csproj
RUN dotnet publish ProviderApi.csproj -c Release -r linux-x64 -o out
FROM microsoft/dotnet:2.0-runtime-deps
WORKDIR /app
COPY -–from=build-env /app/out/ ./
EXPOSE 80
ENTRYPOINT ["./ProviderApi"]
答案 0 :(得分:2)
问题是目标目录不存在于最终构建阶段的docker镜像中。这是工作的Dockerfile供将来参考。
FROM microsoft/aspnetcore-build:2.0.3-stretch AS build-env
WORKDIR /app
COPY . ./
RUN dotnet build ProviderApi.csproj
RUN dotnet publish ProviderApi.csproj -c Release -r linux-x64 -o out
FROM microsoft/aspnetcore:2.0.3-stretch
RUN mkdir /app
COPY --from=build-env /app/out /app
ENV ASPNETCORE_URLS=http://+:5001
EXPOSE 5001
ENTRYPOINT ["/app/ProviderApi"]
答案 1 :(得分:0)
您是否尝试使用小写“as”? (看起来像是一个长镜头,我看到两者的例子)
FROM microsoft/dotnet:2.0-sdk as build-env
或更基本的
FROM microsoft/dotnet:2.0-sdk
COPY -–from=0 /app/out/ ./