A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/app/'.
Hi,
I am getting the following error when deploying donet core 3.0 with docker:
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/app/'.
This is my Dockerfile: ` FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base WORKDIR /app EXPOSE 8080
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build WORKDIR /src COPY ["TestCloudRun.csproj", "TestCloudRun/"] RUN dotnet restore "TestCloudRun/TestCloudRun.csproj" COPY . . WORKDIR "/src/TestCloudRun" RUN dotnet build "TestCloudRun.csproj" -c Release -o /app/build
FROM build AS publish RUN dotnet publish "TestCloudRun.csproj" -c Release -o /app/publish
FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "TestCloudRun.dll"] ` This is the repo: https://github.com/avifatal/core3deployment-issue
I should mention that I'm deploying to google cloud run.
Thanks
You have
<OutputType>Library</OutputType>
in your project file, but it has to be
<OutputType>Exe</OutputType>
with ENTRYPOINT ["dotnet", "TestCloudRun.dll"], shouldn't it be a library? EXE doesn't even make sense for Linux.
Same issue for my web app in .net core 3.1 app
I am facing same issue with .net core app using below base image.
FROM mcr.microsoft.com/dotnet/core/runtime:2.1-stretch-slim AS base FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
the same issue here when running on a linux machine (ubuntu 20.04) from a docker container. FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-focal
same problem on docker for windows (linux container) for self contrained .net core 3.1 app
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
No news about this one? any temporary workaround?
For us, I think it ended up being because we had the following in our csproj, as it was built for windows before converting to Docker.
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
We just had to remove it. We ended up with basically this, which worked, while still using the DLL as the entrypoint in the Dockerfile.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
ENTRYPOINT ["dotnet", "TestCloudRun.dll"]
Same for me
It works on Windows and Ubuntu in WSL 2, but does not work on MacOS latest on M1
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
Error:
Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7
An error occurred while loading required library libhostpolicy.so from [/app/]
Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7
An error occurred while loading required library libhostpolicy.so from [/app/]
So it does not work only in docker on MacOS M1.
We are using aspnet:6.0-alpine3.17 Alpine images
Same for me
It works on Windows and Ubuntu in WSL 2, but does not work on MacOS latest on M1
<PropertyGroup> <TargetFramework>net6.0</TargetFramework> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <PublishTrimmed>true</PublishTrimmed> <PublishReadyToRun>true</PublishReadyToRun> </PropertyGroup>Error:
Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7 An error occurred while loading required library libhostpolicy.so from [/app/] Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7 An error occurred while loading required library libhostpolicy.so from [/app/]So it does not work only in docker on MacOS M1.
We are using aspnet:6.0-alpine3.17 Alpine images
Any update from this. It does not work for me to. Note: I'm using MacOS M1!
Brand new virgin Blazor template throwing this error. I am using Kubuntu
Is this dotnet only? I normally compile my C# programs with
csc -out:"./bin/Program.exe" Program.cs Helper.cs
But when I run netcoredbg I get
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build/bin/'.\nFailed to run as a self-contained app.\n - The application was run as a self-contained app because '/home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build/bin/Program.runtimeconfig.json' was not found.\n - If this should be a framework-dependent app, add the '/home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build/bin/Program.runtimeconfig.json' file and specify the appropriate framework.
But I'm not sure what to put on my runtimeconfig.json or where to find the docs about it. Do you have some example? I'm on linux.
Edit: Ok I managed. But it is quite a pain you have to hardcore the version in the runtimeconfig.json, I cannot distribute the file that way.
I'm facing a similar error, I've already deployed it to a folder and pasted the files into /var/apps/projecs and when executing the dotnet project.dll command it gives the following error
Failed to load /var/apps/control-of-printers/libhostpolicy.so, error: /var/apps/control-of-printers/libhostpolicy.so: cannot open shared object file: No such file or directory An error occurred while loading required library libhostpolicy.so from [/var/apps/control-of-printers/]
I am facing same issues, here the project file of the Web project:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aa193207-78b8-45d6-aa17-725e3bd9939f</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<OutputType>Library</OutputType>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
I am using docker-compose, btw
I have this error without docker using. It happened after I set the Output folder for all projects in the solution to the same (common) folder.
Same for me
It works on Windows and Ubuntu in WSL 2, but does not work on MacOS latest on M1
<PropertyGroup> <TargetFramework>net6.0</TargetFramework> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <PublishTrimmed>true</PublishTrimmed> <PublishReadyToRun>true</PublishReadyToRun> </PropertyGroup>Error:
Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7 An error occurred while loading required library libhostpolicy.so from [/app/] Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7 An error occurred while loading required library libhostpolicy.so from [/app/]So it does not work only in docker on MacOS M1.
We are using aspnet:6.0-alpine3.17 Alpine images
Did you get anywhere @hoangpn256? I'm on an Apple Silicon mac also
In my case my project was build for two target frameworks with net48 OutputPath "bin" and net8.0 OutputPath "bin_dotnet". When I tried debugging with WSL, it tried to start the dll from "bin" instead of "bin_dotnet". I could fix it by deleting the csproj.user file
Same for me It works on Windows and Ubuntu in WSL 2, but does not work on MacOS latest on M1
<PropertyGroup> <TargetFramework>net6.0</TargetFramework> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <PublishTrimmed>true</PublishTrimmed> <PublishReadyToRun>true</PublishReadyToRun> </PropertyGroup>Error:
Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7 An error occurred while loading required library libhostpolicy.so from [/app/] Failed to load /app/libhostpolicy.so, error: Error relocating /app/libhostpolicy.so: unsupported relocation type 7 An error occurred while loading required library libhostpolicy.so from [/app/]So it does not work only in docker on MacOS M1. We are using aspnet:6.0-alpine3.17 Alpine images
Any update from this. It does not work for me to. Note: I'm using MacOS M1!
I'm also working on MacOS M1, and solved this issue by changing linux-x64 to linux-arm64 in this line of docker file
RUN dotnet publish -r linux-arm64 -c Release -o out
hope this able to work with you also
你好,我在debian中运行dotnet *.dll文件遇到了同样的情况,我使用的是linux-arm64