Docker Community Forums

Share and learn in the Docker community.

About Docker build and copy command

I am trying to build an image and I cant run the copy command.

I always get this error and I cant build, but I don’t know why copy command is not working. Anything wrong in my docker file?

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /app

COPY *.sln ./
COPY YangSoft.2.WebAPI/YangSoft.2.WebAPI.csproj ./YangSoft.2.WebAPI/
COPY Application/Application.csproj ./Application/
COPY Core/Core.csproj ./Core/
COPY SharedKernel/SharedKernel.csproj ./SharedKernel/
COPY Infrastructure/Infrastructure.csproj ./Infrastructure/

COPY YS.Tests/YS.Tests.csproj ./YS.Tests/

RUN dotnet restore /app/YangSoft.2.WebAPI/YangSoft.2.WebAPI.csproj

COPY . .
WORKDIR /app/YangSoft.2.WebAPI

FROM build AS publish
RUN dotnet publish "YangSoft.2.WebAPI.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "YangSoft.2.WebAPI.dll"]