Access shared library inside a Docker container

how does docker handle shared libraries
docker run
docker compose shared library
docker .so files
dockerfile
docker stripping
docker linux container
docker shared volume

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).

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

attach shared *.so files to the container? · Issue #181 · rocker-org , with compiled code depend on shared libraries located in /lib or /usr/lib. are the content of '/lib' and '/usr/lib' taken from the docker image or  By default, any data created inside the container is only available from within the container and only while the container is running. Docker volumes can be used to share files between a host system and the Docker container. For example, let’s say you wanted to use the official Docker Nginx image and keep a permanent copy of Nginx’s log files to analyze later. By default, the nginx Docker image will log to the /var/log/nginx directory inside the Docker Nginx container. Normally it’s

This is my DockerFile:

FROM mono:latest
ADD . /src
WORKDIR /src
RUN xbuild BlackBox.csproj
CMD ["mono", "/src/bin/Debug/BlackBox.exe"]

So i have to do something like this:

FROM mono:latest
ADD . /src
WORKDIR /src

RUN apt-get install neededthing another so_on

RUN xbuild BlackBox.csproj
CMD ["mono", "/src/bin/Debug/BlackBox.exe"]

Am I right, @Raedwald?

What do the processes inside a Docker container look like?, Can we check the process of a container inside as well as outside the container? In general, Docker containers are ephemeral, running just as long as it takes for the command issued in the container to complete. Sometimes, however, applications need to share access to data or persist data after a container is deleted.

To access shared libraries inside docker, below is one of the ways:

  1. Use "COPY" command inside Dockerfile to copy the shared libraries/dependencies inside the container. Example: COPY {local_path} {docker_path}
  2. Set the environment variable where shared libraries are searched for first before the standard set of directories. For instance for Linux based OS, LD_LIBRARY_PATH is used. Environment variables can be set via Docker's Environment replacement (ENV) Example: ENV LD_LIBRARY_PATH={docker_path}:$LD_LIBRARY_PATH

How to share data between a Docker container and host , specify (a shell at least). It is not for "sociability" testing. To get access to the container logs you should prefer using the docker logs command. To detach from the container without stopping it, use the CTRL-p CTRL-q key combination. Pressing CTRL-c stops the container. If the running processes you are attaching to accepts input, you can send instructions to it.

How does docker handle shared libraries?, How do I share data between Docker container and host? Docker has been widely adopted and is used to run and scale applications in production. Additionally, it can be used to start applications quickly by executing a single Docker command. Companies also are investing more and more effort into improving development in local and remote Docker containers, which comes with a lot of advantages as well. You can get the basic information about your

How To Share Data between Docker Containers, the filesystem. How does docker utilize shared libraries within its containers? Current Customers and Partners. Log in for full access. Log In  A container isn't much use if you can't easily share or manage its data. Here's how to handle this task with the help of Docker volumes.

Docker frequently asked questions (FAQ), In general, Docker containers are ephemeral, running just as long as it takes for to share access to data or persist data after a container is deleted. In this arti. In our next example, we'll demonstrate how a volume can be shared between  From Docker 1.2 onwards, we can give access of the host device to a container with the --device option to the run command. Earlier, one has bind mount it with the -v option and that had to be done with the --privileged option.

Comments
  • I made my own Docker image with the needed dependencies. The app is running fine now, Thanks!