Repository navigation
Not working in Docker: Unable to load shared library 'git2-106a5f2' or one of its dependencies #1798
Description
Activity
- changed the title
[-]Not working in Docker as self-contained file: Unable to load shared library 'git2-106a5f2' or one of its dependencies[/-][+]Not working in Docker: Unable to load shared library 'git2-106a5f2' or one of its dependencies[/+]on May 28, 2020 This is a known issue. Ubuntu 20.04 isn't going to work right now.
You'll need to an older version of Ubuntu, and when you publish, you likely need to use a more specific RID to ensure you're getting the correct native binary from the package.
This is a known issue. Ubuntu 20.04 isn't going to work right now.
Can you link the issue please :)
Using RID (runtime identifier)
ubuntu.18.04-x64andFROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-bionicworks 👍
Poc-Repo available here, Image available hereHowever alpine with RID
alpine-x64andFROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpinefails:Unhandled exception. System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-106a5f2' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libgit2-106a5f2: No such file or directory at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() at LibGit2Sharp.Core.NativeMethods..cctor() --- End of inner exception stack trace --- at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs) at LibGit2Sharp.Core.Proxy.<>c__DisplayClass219_0.<git_repository_discover>b__0(GitBuf buf) at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) at LibGit2Sharp.Core.Proxy.git_repository_discover(FilePath start_path) at LibGit2Sharp.Repository.Discover(String startingPath) at LibGit2SharpPoc.Program.Main(String[] args) in /home/runner/work/LibGit2SharpPoc/LibGit2SharpPoc/LibGit2SharpPoc/Program.cs:line 11Poc-Repo available here, Image available here
For now I can work with ubuntu-18.04, but it would be very nice if this would work with alpine, because it's very small (which makes it really good for micro-services 😉):
mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpinehas only a size of <10MB, while
mcr.microsoft.com/dotnet/core/runtime-deps:3.1-bionic(ubuntu-18.04) andmcr.microsoft.com/dotnet/core/runtime-deps:3.1-buster-slim(debian) have a size of >100MBIt's talked about in several issues on the repo.
For the alpine image you're trying, you probably need to use the
alpine.3.9-x64RID. You've got to use the RID that will get you the "correct" native library from the LibGit2Sharp.NativeBinaries runtimes folder.Yes, this is all more complicated than I'd like for it to be. Ultimately, the fix is going to be getting #1618 finished, which is slowly happening.
Reacted by litetex and Collin Barrett- added a commit that references this issue
on Sep 23, 2020 - added 2 commits that reference this issue
on Jan 1, 2021

Overview - The workflow
For details see below.
dotnet publish -c Release -r linux-x64 /p:PublishSingleFile=true, which creates a standalone file and requires no dotnet locally installedFROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-focal) is built with this fileHowever locally (on windows) it does not...
I also already checked out other issues, but found no workaround for my case:
Also tried to run / build the project not as self-contained file (without
/p:PublishSingleFile=trueand other modifications likeFROM mcr.microsoft.com/dotnet/core/runtime:3.1-focal) but this also didn't work.Reproduction steps
I created a PoC repo here: https://github.com/litetex/LibGit2SharpPoc
Dockerfile
https://github.com/litetex/LibGit2SharpPoc/blob/develop/build/Dockerfile
Github workflow
https://github.com/litetex/LibGit2SharpPoc/blob/develop/.github/workflows/develop.yml
Project file
Code
Expected behavior
I expect the same behavior, as if I build it locally (
dotnet publish -c Release -r win-x64 /p:PublishSingleFile=true) and execute the file:No crash, exit successfully :)
Actual behavior
When I start the container with:
It crashes with:
Version of LibGit2Sharp (release number or SHA1)
0.26.2 (latest at the moment)
Operating system(s) tested; .NET runtime tested