Skip to content

Docker Linux Container: System.DllNotFoundException: Unable to load shared library 'blake3_dotnet' or one of its dependencies. #21

@Honsal

Description

@Honsal

Entire error msg:

System.DllNotFoundException: Unable to load shared library 'blake3_dotnet' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
/app/bin/Debug/net7.0/runtimes/linux-x64/native/blake3_dotnet.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.11/blake3_dotnet.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/blake3_dotnet.so: cannot open shared object file: No such file or directory
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /app/bin/Debug/net7.0/runtimes/linux-x64/native/libblake3_dotnet.so)
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.11/libblake3_dotnet.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/libblake3_dotnet.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/runtimes/linux-x64/native/blake3_dotnet: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.11/blake3_dotnet: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/blake3_dotnet: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/runtimes/linux-x64/native/libblake3_dotnet: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.11/libblake3_dotnet: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/libblake3_dotnet: cannot open shared object file: No such file or directory

   at Blake3.Hasher.blake3_new()
   at Blake3.Hasher.New()
   at Blake3.Blake3Stream..ctor(Stream backendStream, Boolean dispose)
   at [SENSORED_PROJECT_NAME].Commons.Utilities.HashHelper.ComputeBlake3HashFile(String filePath) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME].Commons\Utilities\HashHelper.cs:line 47
   at [SENSORED_PROJECT_NAME].Services.UploadService.ValidateHash(String tempFilePath, FileInfoDTO fileInfo) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME]\Services\UploadService.cs:line 143
   at [SENSORED_PROJECT_NAME].Services.UploadService.UploadMultipleFileAsync(UploadMultipleFileDTO dto, Int32 clientId) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME]\Services\UploadService.cs:line 236
   at [SENSORED_PROJECT_NAME].Controllers.UploaderApiController.UploadMultipleFileAsync(UploadMultipleFileDTO dto) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME]\Controllers\UploaderApiController.cs:line 103
   at Blake3.Hasher.blake3_new()
   at Blake3.Hasher.New()
   at Blake3.Blake3Stream..ctor(Stream backendStream, Boolean dispose)
   at [SENSORED_PROJECT_NAME].Commons.Utilities.HashHelper.ComputeBlake3HashFile(String filePath) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME].Commons\Utilities\HashHelper.cs:line 47
   at [SENSORED_PROJECT_NAME].Services.UploadService.ValidateHash(String tempFilePath, FileInfoDTO fileInfo) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME]\Services\UploadService.cs:line 143
   at [SENSORED_PROJECT_NAME].Services.UploadService.UploadMultipleFileAsync(UploadMultipleFileDTO dto, Int32 clientId) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME]\Services\UploadService.cs:line 236
   at [SENSORED_PROJECT_NAME].Controllers.UploaderApiController.UploadMultipleFileAsync(UploadMultipleFileDTO dto) in [SENSORED_SOLUTION_PATH]\[SENSORED_PROJECT_NAME]\[SENSORED_PROJECT_NAME]\Controllers\UploaderApiController.cs:line 103

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:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["[SENSORED_PROJECT_NAME]/[SENSORED_PROJECT_NAME].csproj", "[SENSORED_PROJECT_NAME]/"]
RUN dotnet restore "[SENSORED_PROJECT_NAME]/[SENSORED_PROJECT_NAME].csproj"
COPY . .
WORKDIR "/src/[SENSORED_PROJECT_NAME]"
RUN dotnet build "[SENSORED_PROJECT_NAME].csproj" -c Release -o /app/build --os linux --arch x64

FROM build AS publish
RUN dotnet publish "[SENSORED_PROJECT_NAME].csproj" -c Release -o /app/publish /p:UseAppHost=false --os linux --arch x64

FROM base AS final
WORKDIR /app/bin/Release/net7.0-linux-x64/publish
COPY --from=publish /app/publish .
RUN apt-get update && apt-get install -y vim
ENTRYPOINT ["dotnet", "[SENSORED_PROJECT_NAME].dll"]

Container Directory:

/app# ls
Constants    Dockerfile  [SENSORED].csproj       Interfaces        MetalamaAspects  Program.cs  Repositories  Startup.cs  appsettings.Development.json  bin          obj
Controllers  Filters     [SENSORED].csproj.user  MapperProfile.cs  Migrations       Properties  Services      Utilities   appsettings.json              nlog.config
root@84faf2aed7ec:/app# cls 
bash: cls: command not found
root@84faf2aed7ec:/app# clear
root@84faf2aed7ec:/app# ls -la
total 36
drwxrwxrwx 1 root root 4096 Sep 29 11:26 .
drwxr-xr-x 1 root root 4096 Sep 29 11:54 ..
drwxrwxrwx 1 root root 4096 Sep 28 20:14 Constants
drwxrwxrwx 1 root root 4096 Sep 29 11:54 Controllers
-rwxrwxrwx 1 root root  989 Sep 29 10:28 Dockerfile
drwxrwxrwx 1 root root 4096 Sep 28 18:44 Filters
-rwxrwxrwx 1 root root 3750 Sep 28 18:44 [SENSORED].csproj
-rwxrwxrwx 1 root root  580 Sep 28 09:03 [SENSORED].csproj.user
drwxrwxrwx 1 root root 4096 Sep 24 15:05 Interfaces
-rwxrwxrwx 1 root root 1843 Sep 28 18:44 MapperProfile.cs
drwxrwxrwx 1 root root 4096 Sep 14 05:29 MetalamaAspects
drwxrwxrwx 1 root root 4096 Sep 28 18:44 Migrations
-rwxrwxrwx 1 root root  848 Sep 28 20:33 Program.cs
drwxrwxrwx 1 root root 4096 Sep 28 18:44 Properties
drwxrwxrwx 1 root root 4096 Sep 28 18:44 Repositories
drwxrwxrwx 1 root root 4096 Sep 28 18:44 Services
-rwxrwxrwx 1 root root 4808 Sep 29 11:26 Startup.cs
drwxrwxrwx 1 root root 4096 Sep 28 18:44 Utilities
-rwxrwxrwx 1 root root  127 Sep 28 18:44 appsettings.Development.json
-rwxrwxrwx 1 root root  323 Sep 28 20:39 appsettings.json
drwxrwxrwx 1 root root 4096 Sep 28 20:16 bin
-rwxrwxrwx 1 root root 1891 Sep 28 19:52 nlog.config
drwxrwxrwx 1 root root 4096 Sep 28 18:17 obj

Addition:

It works well if launch on windows 11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions