I am playing with the Microservices application with docker enable in my local development.
after i completely setup my project. i try to manipulate the project with docker building command.
since the dockerfile had been automatically generated by visual studio, when i create a dotnet core web api project with docker support.
how ever when i run this command to create a docker image
docker build . -t myimage -f dockerfile
it encountered an error on the copy step. i put the step with error in bold.
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
RUN dotnet restore "simplemicroservicesApp/simplemicroservicesApp.csproj"
COPY . .
WORKDIR "/src/simplemicroservicesApp"
RUN dotnet build "simplemicroservicesApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "simplemicroservicesApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "simplemicroservicesApp.dll"]
here is the error message
Step 7/17 : COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder663072116/simplemicroservicesApp/simplemicroservicesApp.csproj: no such file or directory
the root of cause of this issue is that Visual Studio generated the dockerfile inside the project folder. actually it should be in the solution folder.
by default the dockerfile was generated inside the project folder
actually it should be in the solution level in order to build a docker image properly.
after i cut and paste the file into the solution folder, then navigate to the solution folder in window CMD, and execute the following line to create a docker image.
docker build . -t myimage -f dockerfile
For me, the fix was to place the project in a directory one level down. Docker is getting hung up on "COPY . ."
ReplyDeleteit depends on the error you encounter
ReplyDelete