Docker Community Forums

Share and learn in the Docker community.

Shared library error when 'make' in build, but compiles fine when I run the image


I am trying to build a docker image, and one of the required libraries is MeCab. This library contains two parts, the software itself and the dictionary. When I tried to build a docker image using docker build, I get the following error message:

/usr/local/libexec/mecab/mecab-dict-index: error while loading shared libraries: cannot open shared object file: No such file or directory is part of the software which is already make and make install, but when I tried to make the dictionary, it cannot find the above library. If I stop the docker build at the RUN step before this error, docker run the built image, then run the same make command, it works… so the is definitely properly installed, but for some reason docker build can’t find it…?

Any suggestions would be much appreciated, thanks!

Hi buddy, try to build the loops after the gaps it should work well then.

Hi, sorry not sure what you mean by loops and gaps, could you please explain?

Hi @dannycheng and @nodrojelmo ,
I am facing the same problem, can you please give some advices.

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

Use “COPY” command inside Dockerfile to copy the shared libraries/dependencies inside the container. Example: COPY {local_path} {docker_path}
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