Welcome to the Linux Foundation Forum!

How does the use of dynamic libraries (shared objects) work in a container?

Hello, I'm starting studies with container.

I would like to understand how the use of dynamic libraries (shared objects) of the docker works. When the container runs an opensuse image equivalent to the host machine's version, will it use the same libraries? Is there any way to capture the libraries used by a specific container?

Answers

  • My understanding is that your container will not have access to the host shared objects (a.k.a your .so library files) by default. Not even if you run an "equivalent" operating system inside the container.

    Containers are isolated environments - they live in a virtual world inside your host machine. There are a few ways they can access your host machine filesystem, like bind mounts, but you are the one responsible for setting that up.

    Your problem is that you have a library in your host machine that maybe you want to share with the container. My solution would be to create the container and then either share the library via something like a bind mount (not sure if that would work) or even better, docker copy it from the host to the container.

    After you set up your container you can then docker commit it to an image and have all your changes saved for later on creating new containers with the same library.

Categories

Upcoming Training