C
C#10mo ago
Batuhan

Can not create Docker Image in Terminal using DockerFile

Hi, I am trying to dockerize my microservice application and my identityserver runs on 3.1 sdk because it is free version. I have the default visual studio's dockerfile and when I start project using visual studio with dockerfile it runs there is no problem. Hence i try to build image on my terminal i get this error and could not find the proper solution.
5 Replies
Batuhan
BatuhanOP10mo ago
My Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 5002
EXPOSE 5003

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj", "IdentityServer/Course.IdentityServer/"]
RUN dotnet restore "./IdentityServer/Course.IdentityServer/./Course.IdentityServer.csproj"
COPY . .
WORKDIR "/src/IdentityServer/Course.IdentityServer"
RUN dotnet build "./Course.IdentityServer.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Course.IdentityServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Course.IdentityServer.dll"]
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 5002
EXPOSE 5003

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj", "IdentityServer/Course.IdentityServer/"]
RUN dotnet restore "./IdentityServer/Course.IdentityServer/./Course.IdentityServer.csproj"
COPY . .
WORKDIR "/src/IdentityServer/Course.IdentityServer"
RUN dotnet build "./Course.IdentityServer.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Course.IdentityServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Course.IdentityServer.dll"]
and this is the error i get
=> ERROR [build 3/7] COPY [IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj, IdentityServer/Course.IdentityServer/] 0.0s
------
> [build 3/7] COPY [IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj, IdentityServer/Course.IdentityServer/]:
------
Dockerfile:9
--------------------
7 | ARG BUILD_CONFIGURATION=Release
8 | WORKDIR /src
9 | >>> COPY ["IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj", "IdentityServer/Course.IdentityServer/"]
10 | RUN dotnet restore "./IdentityServer/Course.IdentityServer/./Course.IdentityServer.csproj"
11 | COPY . .
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref bbe3e021-99e0-463c-b63f-1efe01732795::xx41dfzv9hzte05cgw51kjojl: "/IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj": not found
=> ERROR [build 3/7] COPY [IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj, IdentityServer/Course.IdentityServer/] 0.0s
------
> [build 3/7] COPY [IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj, IdentityServer/Course.IdentityServer/]:
------
Dockerfile:9
--------------------
7 | ARG BUILD_CONFIGURATION=Release
8 | WORKDIR /src
9 | >>> COPY ["IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj", "IdentityServer/Course.IdentityServer/"]
10 | RUN dotnet restore "./IdentityServer/Course.IdentityServer/./Course.IdentityServer.csproj"
11 | COPY . .
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref bbe3e021-99e0-463c-b63f-1efe01732795::xx41dfzv9hzte05cgw51kjojl: "/IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj": not found
also my command
docker build -t aspnetcoreapp .
docker build -t aspnetcoreapp .
Xymanek
Xymanek10mo ago
Use triple backticks for code blocks (easier to read) $code
MODiX
MODiX10mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Batuhan
BatuhanOP10mo ago
thanks for the advice
Xymanek
Xymanek10mo ago
"/IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj": not found
"/IdentityServer/Course.IdentityServer/Course.IdentityServer.csproj": not found
That's the error
Want results from more Discord servers?
Add your server