ncoreCoder
ncoreCoder

Reputation: 11

Dockerfile build image fail

Project Structure:

Syslog.Sample
--docker.Sample
--Syslog.Sample

Project "docker.Sample" -> Add Docker support. This is the content of the generated Dockerfile:

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

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["docker.Sample/docker.Sample.csproj", "docker.Sample/"]
RUN dotnet restore "docker.Sample/docker.Sample.csproj"
COPY . .
WORKDIR "/src/docker.Sample"
RUN dotnet build "docker.Sample.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "docker.Sample.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "docker.Sample.dll"]

Run command "docker build ."

output fail context message:

failed to solve with frontend dockerfile.v0: failed to build LLB: failed to compute cache key: "/docker.Sample/docker.Sample.csproj" not found: not found

help me

Upvotes: 1

Views: 5211

Answers (1)

amnaw
amnaw

Reputation: 95

This is how I made it work: change this

COPY ["docker.Sample/docker.Sample.csproj", "docker.Sample/"]

to this

COPY ["docker.Sample.csproj", "docker.Sample/"].

Remove the directory name of the csproj. For some reason the default Dockerfile created by VS is faulty.

Upvotes: 8

Related Questions