skip to Main Content

I have been hitting my head at this problem for weeks now and i cant seem to find a reason why docker suddenly cant find my projects anymore. For context i use the auto dockerfile gen on Visual Studio that has worked for years. But suddenly a month ago or so. it just stopped being able to find any project.

The dockerfile

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["RESTAPI/RESTAPI.csproj", "RESTAPI/"]
COPY ["Domain/Domain.csproj", "Domain/"]
COPY ["JsonService/JsonService.csproj", "JsonService/"]
COPY ["JsonRepository/JsonRepository.csproj", "JsonRepository/"]
RUN dotnet restore "./RESTAPI/RESTAPI.csproj"
COPY . .
WORKDIR "/src/RESTAPI"
RUN dotnet build "./RESTAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build

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

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

docker error

2024/05/05 18:17:53 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
[+] Building 0.0s (0/0)  docker:default
2024/05/05 18:17:53 http2: server: error reading preface from client //./pipe/docker_engine: file has already been close[+] Building 0.2s (12/20)                                                                                docker:default
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 1.04kB                                                                             0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0                                                  0.2s
 => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:8.0                                               0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [build  1/10] FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:03476e8b974ca8e5084bf63742d85f04a5f53df0ae37c82d31  0.0s
 => [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:8.0                                                            0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 8.65kB                                                                                0.0s
 => CACHED [build  2/10] WORKDIR /src                                                                              0.0s
 => ERROR [build  3/10] COPY [RESTAPI/RESTAPI.csproj, RESTAPI/]                                                    0.0s
 => ERROR [build  4/10] COPY [Domain/Domain.csproj, Domain/]                                                       0.0s
 => ERROR [build  5/10] COPY [JsonService/JsonService.csproj, JsonService/]                                        0.0s
 => ERROR [build  6/10] COPY [JsonRepository/JsonRepository.csproj, JsonRepository/]                               0.0s
------
 > [build  3/10] COPY [RESTAPI/RESTAPI.csproj, RESTAPI/]:
------
------
 > [build  4/10] COPY [Domain/Domain.csproj, Domain/]:
------
------
 > [build  5/10] COPY [JsonService/JsonService.csproj, JsonService/]:
------
------
 > [build  6/10] COPY [JsonRepository/JsonRepository.csproj, JsonRepository/]:
------
Dockerfile:15
--------------------
  13 |     COPY ["Domain/Domain.csproj", "Domain/"]
  14 |     COPY ["JsonService/JsonService.csproj", "JsonService/"]
  15 | >>> COPY ["JsonRepository/JsonRepository.csproj", "JsonRepository/"]
  16 |     RUN dotnet restore "./RESTAPI/RESTAPI.csproj"
  17 |     COPY . .
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 7d361eef-1f98-4f82-921b-eb8642d4e9e0::7zd4dryeosmuxw0c8pztwiwua: "/JsonRepository/JsonRepository.csproj": not found

and finally my file tree

G:.
│   .dockerignore
│   .gitignore
│   JSONRequestHub.sln
│
├───Domain
│   │   Domain.csproj
│   │
│   ├───BasicJson
│   │       JsonAddress.cs
│   │       JsonArticle.cs
│   │       JsonComment.cs
│   │       JsonEvent.cs
│   │       JsonFinancialTransaction.cs
│   │       JsonOrder.cs
│   │       JsonProduct.cs
│   │       JsonRandom.cs
│   │       JsonUser.cs
│   │
│   ├───bin
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │           Domain.deps.json
│   │   │           Domain.dll
│   │   │           Domain.pdb
│   │   │
│   │   └───Release
│   │       └───net8.0
│   ├───Enums
│   │       ObjectTypes.cs
│   │
│   ├───obj
│   │   │   Domain.csproj.nuget.dgspec.json
│   │   │   Domain.csproj.nuget.g.props
│   │   │   Domain.csproj.nuget.g.targets
│   │   │   project.assets.json
│   │   │   project.nuget.cache
│   │   │
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│   │   │       │   Domain.AssemblyInfo.cs
│   │   │       │   Domain.AssemblyInfoInputs.cache
│   │   │       │   Domain.assets.cache
│   │   │       │   Domain.csproj.AssemblyReference.cache
│   │   │       │   Domain.csproj.BuildWithSkipAnalyzers
│   │   │       │   Domain.csproj.CoreCompileInputs.cache
│   │   │       │   Domain.csproj.FileListAbsolute.txt
│   │   │       │   Domain.dll
│   │   │       │   Domain.GeneratedMSBuildEditorConfig.editorconfig
│   │   │       │   Domain.GlobalUsings.g.cs
│   │   │       │   Domain.pdb
│   │   │       │   Domain.sourcelink.json
│   │   │       │
│   │   │       ├───ref
│   │   │       │       Domain.dll
│   │   │       │
│   │   │       └───refint
│   │   │               Domain.dll
│   │   │
│   │   └───Release
│   │       └───net8.0
│   │           │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│   │           │   Domain.AssemblyInfo.cs
│   │           │   Domain.AssemblyInfoInputs.cache
│   │           │   Domain.assets.cache
│   │           │   Domain.csproj.AssemblyReference.cache
│   │           │   Domain.GeneratedMSBuildEditorConfig.editorconfig
│   │           │   Domain.GlobalUsings.g.cs
│   │           │
│   │           ├───ref
│   │           └───refint
│   └───Shared
│           Settings.cs
│
├───JsonRepository
│   │   BasicJsonRepository.cs
│   │   IBasicJsonRepository.cs
│   │   JsonGenerate.cs
│   │   JsonGetData.cs
│   │   JsonRepository.csproj
│   │   MongoDbContext.cs
│   │
│   ├───bin
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │           Domain.dll
│   │   │           Domain.pdb
│   │   │           JsonRepository.deps.json
│   │   │           JsonRepository.dll
│   │   │           JsonRepository.pdb
│   │   │
│   │   └───Release
│   │       └───net8.0
│   └───obj
│       │   JsonRepository.csproj.nuget.dgspec.json
│       │   JsonRepository.csproj.nuget.g.props
│       │   JsonRepository.csproj.nuget.g.targets
│       │   project.assets.json
│       │   project.nuget.cache
│       │
│       ├───Debug
│       │   └───net8.0
│       │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│       │       │   JsonRepo.65D78EE7.Up2Date
│       │       │   JsonRepository.AssemblyInfo.cs
│       │       │   JsonRepository.AssemblyInfoInputs.cache
│       │       │   JsonRepository.assets.cache
│       │       │   JsonRepository.csproj.AssemblyReference.cache
│       │       │   JsonRepository.csproj.BuildWithSkipAnalyzers
│       │       │   JsonRepository.csproj.CoreCompileInputs.cache
│       │       │   JsonRepository.csproj.FileListAbsolute.txt
│       │       │   JsonRepository.dll
│       │       │   JsonRepository.GeneratedMSBuildEditorConfig.editorconfig
│       │       │   JsonRepository.GlobalUsings.g.cs
│       │       │   JsonRepository.pdb
│       │       │   JsonRepository.sourcelink.json
│       │       │
│       │       ├───ref
│       │       │       JsonRepository.dll
│       │       │
│       │       └───refint
│       │               JsonRepository.dll
│       │
│       └───Release
│           └───net8.0
│               │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│               │   JsonRepository.AssemblyInfo.cs
│               │   JsonRepository.AssemblyInfoInputs.cache
│               │   JsonRepository.assets.cache
│               │   JsonRepository.csproj.AssemblyReference.cache
│               │   JsonRepository.GeneratedMSBuildEditorConfig.editorconfig
│               │   JsonRepository.GlobalUsings.g.cs
│               │
│               ├───ref
│               └───refint
├───JsonService
│   │   BasicJsonService.cs
│   │   IBasicJsonService.cs
│   │   JsonService.csproj
│   │
│   ├───bin
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │           Domain.dll
│   │   │           Domain.pdb
│   │   │           JsonRepository.dll
│   │   │           JsonRepository.pdb
│   │   │           JsonService.deps.json
│   │   │           JsonService.dll
│   │   │           JsonService.pdb
│   │   │
│   │   └───Release
│   │       └───net8.0
│   └───obj
│       │   JsonService.csproj.nuget.dgspec.json
│       │   JsonService.csproj.nuget.g.props
│       │   JsonService.csproj.nuget.g.targets
│       │   project.assets.json
│       │   project.nuget.cache
│       │
│       ├───Debug
│       │   └───net8.0
│       │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│       │       │   JsonServ.FF3E0D47.Up2Date
│       │       │   JsonService.AssemblyInfo.cs
│       │       │   JsonService.AssemblyInfoInputs.cache
│       │       │   JsonService.assets.cache
│       │       │   JsonService.csproj.AssemblyReference.cache
│       │       │   JsonService.csproj.BuildWithSkipAnalyzers
│       │       │   JsonService.csproj.CoreCompileInputs.cache
│       │       │   JsonService.csproj.FileListAbsolute.txt
│       │       │   JsonService.dll
│       │       │   JsonService.GeneratedMSBuildEditorConfig.editorconfig
│       │       │   JsonService.GlobalUsings.g.cs
│       │       │   JsonService.pdb
│       │       │   JsonService.sourcelink.json
│       │       │
│       │       ├───ref
│       │       │       JsonService.dll
│       │       │
│       │       └───refint
│       │               JsonService.dll
│       │
│       └───Release
│           └───net8.0
│               │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│               │   JsonService.AssemblyInfo.cs
│               │   JsonService.AssemblyInfoInputs.cache
│               │   JsonService.assets.cache
│               │   JsonService.csproj.AssemblyReference.cache
│               │   JsonService.GeneratedMSBuildEditorConfig.editorconfig
│               │   JsonService.GlobalUsings.g.cs
│               │
│               ├───ref
│               └───refint
└───RESTAPI
    │   appsettings.Development.json
    │   appsettings.json
    │   Dockerfile
    │   Dockerfile.original
    │   Dockerfile1.original
    │   Program.cs
    │   RESTAPI.csproj
    │   RESTAPI.csproj.user
    │
    ├───bin
    │   ├───Debug
    │   │   └───net8.0
    │   │       │   appsettings.Development.json
    │   │       │   appsettings.json
    │   │       │   AWSSDK.Core.dll
    │   │       │   AWSSDK.SecurityToken.dll
    │   │       │   DnsClient.dll
    │   │       │   Domain.dll
    │   │       │   Domain.pdb
    │   │       │   JsonRepository.dll
    │   │       │   JsonRepository.pdb
    │   │       │   JsonService.dll
    │   │       │   JsonService.pdb
    │   │       │   Microsoft.Extensions.DependencyModel.dll
    │   │       │   Microsoft.Extensions.Options.dll
    │   │       │   Microsoft.OpenApi.dll
    │   │       │   MongoDB.Bson.dll
    │   │       │   MongoDB.Driver.Core.dll
    │   │       │   MongoDB.Driver.dll
    │   │       │   MongoDB.Libmongocrypt.dll
    │   │       │   RESTAPI.deps.json
    │   │       │   RESTAPI.dll
    │   │       │   RESTAPI.exe
    │   │       │   RESTAPI.pdb
    │   │       │   RESTAPI.runtimeconfig.json
    │   │       │   RESTAPI.xml
    │   │       │   Serilog.AspNetCore.dll
    │   │       │   Serilog.dll
    │   │       │   Serilog.Enrichers.Environment.dll
    │   │       │   Serilog.Extensions.Hosting.dll
    │   │       │   Serilog.Extensions.Logging.dll
    │   │       │   Serilog.Formatting.Compact.dll
    │   │       │   Serilog.Settings.Configuration.dll
    │   │       │   Serilog.Sinks.Console.dll
    │   │       │   Serilog.Sinks.Debug.dll
    │   │       │   Serilog.Sinks.File.dll
    │   │       │   Serilog.Sinks.PeriodicBatching.dll
    │   │       │   Serilog.Sinks.Seq.dll
    │   │       │   SharpCompress.dll
    │   │       │   Snappier.dll
    │   │       │   Swashbuckle.AspNetCore.Swagger.dll
    │   │       │   Swashbuckle.AspNetCore.SwaggerGen.dll
    │   │       │   Swashbuckle.AspNetCore.SwaggerUI.dll
    │   │       │   ZstdSharp.dll
    │   │       │
    │   │       └───runtimes
    │   │           ├───linux
    │   │           │   └───native
    │   │           │           libmongocrypt.so
    │   │           │
    │   │           ├───osx
    │   │           │   └───native
    │   │           │           libmongocrypt.dylib
    │   │           │
    │   │           └───win
    │   │               └───native
    │   │                       mongocrypt.dll
    │   │
    │   └───Release
    │       └───net8.0
    ├───Controllers
    │       BasicJsonController.cs
    │
    ├───Middleware
    │       IpRateLimitMiddleware.cs
    │
    ├───obj
    │   │   project.assets.json
    │   │   project.nuget.cache
    │   │   RESTAPI.csproj.nuget.dgspec.json
    │   │   RESTAPI.csproj.nuget.g.props
    │   │   RESTAPI.csproj.nuget.g.targets
    │   │
    │   ├───Debug
    │   │   └───net8.0
    │   │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
    │   │       │   apphost.exe
    │   │       │   RESTAPI.AssemblyInfo.cs
    │   │       │   RESTAPI.AssemblyInfoInputs.cache
    │   │       │   RESTAPI.assets.cache
    │   │       │   RESTAPI.csproj.AssemblyReference.cache
    │   │       │   RESTAPI.csproj.BuildWithSkipAnalyzers
    │   │       │   RESTAPI.csproj.CoreCompileInputs.cache
    │   │       │   RESTAPI.csproj.FileListAbsolute.txt
    │   │       │   RESTAPI.csproj.Up2Date
    │   │       │   RESTAPI.dll
    │   │       │   RESTAPI.GeneratedMSBuildEditorConfig.editorconfig
    │   │       │   RESTAPI.genruntimeconfig.cache
    │   │       │   RESTAPI.GlobalUsings.g.cs
    │   │       │   RESTAPI.MvcApplicationPartsAssemblyInfo.cache
    │   │       │   RESTAPI.MvcApplicationPartsAssemblyInfo.cs
    │   │       │   RESTAPI.pdb
    │   │       │   RESTAPI.sourcelink.json
    │   │       │   RESTAPI.xml
    │   │       │   staticwebassets.build.json
    │   │       │
    │   │       ├───ref
    │   │       │       RESTAPI.dll
    │   │       │
    │   │       ├───refint
    │   │       │       RESTAPI.dll
    │   │       │
    │   │       └───staticwebassets
    │   │               msbuild.build.RESTAPI.props
    │   │               msbuild.buildMultiTargeting.RESTAPI.props
    │   │               msbuild.buildTransitive.RESTAPI.props
    │   │
    │   └───Release
    │       └───net8.0
    │           │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
    │           │   RESTAPI.AssemblyInfo.cs
    │           │   RESTAPI.AssemblyInfoInputs.cache
    │           │   RESTAPI.assets.cache
    │           │   RESTAPI.csproj.AssemblyReference.cache
    │           │   RESTAPI.GeneratedMSBuildEditorConfig.editorconfig
    │           │   RESTAPI.GlobalUsings.g.cs
    │           │
    │           ├───ref
    │           └───refint
    └───Properties
            launchSettings.json

if you can help me. thanks in advance i lost hope at this point it could be simple error that i have missed or something else.

tried to move in to a new drive still failed

reinstalled docker too see if that fixed it, it did not.

asked AI more times then i remeber to if they knew the answer other then it cant find your file.

installed linux ported files over runned the command and it still fails..

2

Answers


  1. Chosen as BEST ANSWER

    Soo i have found a solution apperently docker compose works fine ????? i have no clue why that works


  2. Your Dockerfile is in the RESTAPI directory, but is written in a way that assumes that the parent directory is the build context.

    If you are in the RESTAPI directory and do

    docker build -t myimage .
    

    it will fail because the context is the RESTAPI directory and not the parent directory.

    If you set the context to the parent directory, like this

    docker build -t myimage ..
    

    (e.g. with 2 periods at the end) it should work.

    Your docker compose file probably sets the build context correctly and that’s why it works from there.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search