dockermonoshared-librariesraspberry-pi3linphone

Access shared library inside a Docker container


Goal:
Deploying a Docker container that can access the hosts shared libraries (liblinphone.so) or can access the installation of liphone on the host.

Soft-hardware in use:
- Raspberry Pi compute module
- Mono (C#)
- Linphone with C# wrapper
- Docker

Summary:
I am writing code for a RPi3 in Mono(C#). This code uses the GPIO's and a linphone installion (a Linphone ARM version is installed on this system). The code does run flawless on native Mono. My next goal is to run it inside a Docker container. For this I did setup a private Gitlab server, Docker registry and a Gitlab pipeline to make a Docker image. The Docker image gets build without any errors. When I run the code it can't find the liblinphone.so file, obviously.. but I don't know how to.

Docker run command:

docker run --privileged -v /etc/ld.so.cache:/etc/ld.so.cache -v /etc/ld.so.conf.d/:/etc/ld.so.conf.d/ -v /usr/local/lib/:/usr/local/lib/ -v /var/run/docker.sock:/var/run/docker.sock [registry]:5000/[image]:latest

I added some volumes where the .so file and some references are located (some volumes aren't necessary). The --privileged part is to access the GPIO's.

Error:

Unhandled Exception:
System.DllNotFoundException: linphone assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Linphone.Core.linphone_core_set_log_level_mask(uint)
  at Linphone.Core.SetLogLevelMask (System.UInt32 mask) [0x00001] in <5285048db55d447fae3be4c32e253dbd>:0 
  at BlackBox.Phone.CreatePhone (System.String username, System.String password, System.String server, System.Int32 port, System.String agent, System.String version) [0x00001] in <5285048db55d447fae3be4c32e253dbd>:0 
  at BlackBox.BlackBox..ctor (BlackBox.BlackBox+AppFunction appFunction) [0x00198] in <5285048db55d447fae3be4c32e253dbd>:0 
  at BlackBox.MainClass.Main (System.String[] args) [0x00001] in <5285048db55d447fae3be4c32e253dbd>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: linphone assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Linphone.Core.linphone_core_set_log_level_mask(uint)
  at Linphone.Core.SetLogLevelMask (System.UInt32 mask) [0x00001] in <5285048db55d447fae3be4c32e253dbd>:0 
  at BlackBox.Phone.CreatePhone (System.String username, System.String password, System.String server, System.Int32 port, System.String agent, System.String version) [0x00001] in <5285048db55d447fae3be4c32e253dbd>:0 
  at BlackBox.BlackBox..ctor (BlackBox.BlackBox+AppFunction appFunction) [0x00198] in <5285048db55d447fae3be4c32e253dbd>:0 
  at BlackBox.MainClass.Main (System.String[] args) [0x00001] in <5285048db55d447fae3be4c32e253dbd>:0 

My guess is that I can't mount the linphone .so/installation. but instead that I have to mount the docker socket and run it natively on the host. also that didn't get me success (due to ignorance).


Solution

  • In the Dockerfile that builds the container, run the installation commands that install the package that provides the shared library.