Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Running in Alpine Linux docker container fails with System.IO.IOException: Error loading native library "/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so" #15605

Closed
cypressious opened this issue Jun 1, 2018 · 6 comments

Comments

@cypressious
Copy link

cypressious commented Jun 1, 2018

What version of gRPC and what language are you using?

C#, 1.12.0

What operating system (Linux, Windows, …) and version?

Docker, Alpine Linux

What runtime / compiler are you using (e.g. python version or version of gcc)

.NET Core 2.1

What did you do?

Created a ASP.NET Core 2.1 project and Dockerfile using an Alpine Linux base image.

FROM microsoft/dotnet:2.1.300-sdk-alpine AS builder
WORKDIR /

COPY . .
RUN dotnet publish WebApplication2/WebApplication2.csproj -o /dockerout/ -c Release

FROM microsoft/dotnet:2.1.0-aspnetcore-runtime-alpine
WORKDIR /app
EXPOSE 80

COPY --from=builder /dockerout .

ENTRYPOINT ["dotnet", "WebApplication2.dll"]

See https://github.com/cypressious/grpc-docker-issue for a reproducible sample.

What did you expect to see?

The application working

What did you see instead?

Unhaled Exception: System.IO.IOException: Error loading native library "/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.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 WebApplication2.Startup.ConfigureServices(IServiceCollection services) in /WebApplication2/Startup.cs:line 16
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at WebApplication2.Program.Main(String[] args) in /WebApplication2/Program.cs:line 17

Anything else we should know about your project / environment?

Changing the Dockerfile to use a non-alpine image makes it work correctly

FROM microsoft/dotnet:2.1.300-sdk AS builder
WORKDIR /

COPY . .
RUN dotnet publish WebApplication2/WebApplication2.csproj -o /dockerout/ -c Release

FROM microsoft/dotnet:2.1.0-aspnetcore-runtime
WORKDIR /app
EXPOSE 80

COPY --from=builder /dockerout .

ENTRYPOINT ["dotnet", "WebApplication2.dll"]
@dmccaffery
Copy link

Just hit the same issue, same error, same stack trace... :feelsgood:

@vadimi
Copy link

vadimi commented Jun 1, 2018

It worked for me when I installed libc6-compat:

RUN apk update && apk add libc6-compat

@dmccaffery
Copy link

Hmm. I thought I tried that. I will double check.

@cypressious
Copy link
Author

@vadimi this seems to have done the trick. thanks

@jtattermusch
Copy link
Contributor

We don't have a distrib test currently for testing our nugets on alpine linux, we should consider adding it in the future. Otherwise, there's not much we can do about this.

@jtattermusch
Copy link
Contributor

Closing this issue as things seem to be working fine if the right prerequisites are installed.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants