加载本机库时出错“/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so - Docker 容器上的 Grpc 核心 [英] Error loading native library "/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so - Grpc Core on Docker container

查看:64
本文介绍了加载本机库时出错“/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so - Docker 容器上的 Grpc 核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 .NET Core 和 gRPC 为 Csharp 构建一个 Web API 应用.

I'm build a web API app using .NET core and gRPC for Csharp.

在本地,它工作得很好,但是当我构建容器并在 Docker 桌面上运行它时,调用方法时收到错误:

In Local, It work verry well, but when I build container and run it on Docker Desktop, receive error when I call method:

System.IO.IOException: Error loading native library "/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so". Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/runtimes/linux/native/libgrpc_csharp_ext.x64.so)
   at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
   at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
   at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
   at Grpc.Core.Internal.NativeExtension..ctor()
   at Grpc.Core.Internal.NativeExtension.Get()
   at Grpc.Core.Internal.NativeMethods.Get()
   at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
   at Grpc.Core.GrpcEnvironment..ctor()
   at Grpc.Core.GrpcEnvironment.AddRef()
   at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options)
   at Net.Core.Grpc.IPEndpointStrategy.SetCallInvokers(String serviceName, Boolean filterBlack)
   at Net.Core.Grpc.IPEndpointStrategy.Get(String serviceName)
   at Net.Core.Grpc.ClientCallInvoker.Call[TResponse](Func`2 call, Int32 retryLeft)
   at Net.Core.Grpc.ClientCallInvoker.AsyncUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<AsyncUnaryCall>b__4_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
   at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.AsyncUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, AsyncUnaryCallContinuation`2 continuation)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.AsyncUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at INRES.Service.Category.GetAllDvhcService.GetAllDvhcServiceClient.GetAllDvhcAsync(GetAllDvhcRequest request, CallOptions options)
   at INRES.Service.Category.GetAllDvhcService.GetAllDvhcServiceClient.GetAllDvhcAsync(GetAllDvhcRequest request, Metadata headers, Nullable`1 deadline, CancellationToken cancellationToken)
   at iNRES.Service.Meteorology.Domain.QueryHandlers.TramkttvQueryHandler.Handle(GetTramkttvQuery request, CancellationToken cancellationToken) in /app/src/iNRES.Service.Meteorology/Domain/QueryHandlers/TramkttvQueryHandler.cs:line 66
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at iNRES.Service.Meteorology.Controllers.BaseController.QueryAsync[TResult](IRequest`1 query) in /app/src/iNRES.Service.Meteorology/Controllers/BaseController.cs:line 45
   at iNRES.Service.Meteorology.Controllers.MtTramkttvController.GetById(Int32 id) in /app/src/iNRES.Service.Meteorology/Controllers/MtTramkttvController.cs:line 39
   at 

这是我的 Docker 文件:

This is my Docker file:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /app
ARG sln=myproject.sln
ARG service=src/myproject
ARG configuration=Release
COPY ${sln} ./
COPY ./${service} ./${service}/
COPY ./${tests} ./${tests}/
RUN apk update && apk add libc6-compat
RUN dotnet restore /property:Configuration=${configuration}
COPY . ./
RUN dotnet publish ${service} -c ${configuration} -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine as runtime
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.8/main' >> /etc/apk/repositories && apk update --no-cache && apk add --no-cache bash libc6-compat=1.1.19-r11
WORKDIR /app
COPY --from=build /app/${service}/${configuration}/out .
ENV ASPNETCORE_URLS http://*:5000
ENV ASPNETCORE_ENVIRONMENT docker
EXPOSE 5000
ENTRYPOINT dotnet myproject.dll

推荐答案

对于那些在 Raspberry Pi 上遇到过这个错误的人来说,问题是 libgrpc_csharp_ext 原生库目前没有为 arm7 处理器编译和构建.我通过自己使用 this 方法为 arm7 编译 gRPC 使其工作.现在一切正常.

For those who have encounterd this error on Raspberry Pi, the problem is the libgrpc_csharp_ext native library is currently not compiled and built for the arm7 processor. I made it work by compiling the gRPC for arm7 by myself using this method. Now everything works just as expected.

您还可以在此处找到有关此问题的博客:https://dev.to/erikest/grpc-on-dotnet-core-preview3-on-raspberrypi-3-4nf4

You can also find blog about this problem here: https://dev.to/erikest/grpc-on-dotnet-core-preview3-on-raspberrypi-3-4nf4

这篇关于加载本机库时出错“/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so - Docker 容器上的 Grpc 核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆