Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

c++ - docker cannot find libraries that are there

I am facing a strange issue. I have a dockerfile for a executable I have created. Obviously it runs perfectly outside the docker. My docker file has several lines like:

COPY libaws-cpp-sdk-s3.so /usr/local/lib/
COPY libaws-cpp-sdk-core.so  /usr/local/lib/
COPY libaws-c-event-stream.so.0unstable /usr/local/lib/
COPY libvtkIOImage-9.0.so.1 /usr/local/lib/
COPY libvtkImagingCore-9.0.so.1 /usr/local/lib/

These libraries it does find correctly... but SOME other libraries it simply does not find . As for example...

COPY libvtkDICOMParser-9.0.so.1 /usr/local/lib/ 

I should not have to change anything to the LD library path since the other libraries are found. Even with that I have tried to set the LD_LIBRARY_PATH but it changes absolutely nothing.

I have changed the final command in the Dockerfile to be an ldd to try to figure the problem and it simply cannot find libraries that are there, at the very same place that other libraries that it can see, are also located.

Does anyone ever faced something like that with Docker?

Here the whole Dcokerfile, notice I changed the final commmand for an ldd exactly to check what was failing. The docker print is just after the Dockerfile. Notice the libvtkDICOMParser-9.0.so.1 as an example of library that is copied but the ldd cannot find it inside docker (outside the docker it works fine)

FROM ubuntu:focal
run apt-get update && 
    apt-get install -y libicu-dev libcurl4 libwrap0-dev  libgl1-mesa-dev
RUN apt install -y mesa-common-dev
RUN apt install -y libosmesa6-dev
RUN apt install -y libglu1-mesa-dev
RUN apt install -y libjpeg8

ENV PORT 4200
EXPOSE 4200
WORKDIR /server

COPY remote_server ./


COPY libvtkCommonTransforms-9.0.so.1 /usr/local/lib/

COPY libvtkDICOMParser-9.0.so.1 ./
COPY libaws-cpp-sdk-s3.so /usr/local/lib/
COPY libaws-cpp-sdk-core.so  /usr/local/lib/
COPY libaws-c-event-stream.so.0unstable /usr/local/lib/
COPY libaws-checksums.so /usr/local/lib/
COPY libaws-c-common.so.0unstable /usr/local/lib/
COPY libcharls.so.14 /usr/local/lib/
COPY libcmr.so.14 /usr/local/lib/
COPY libdcmdata.so.14 /usr/local/lib/
COPY libdcmdsig.so.14 /usr/local/lib/
COPY libdcmfg.so.14 /usr/local/lib/
COPY libdcmimage.so.14 /usr/local/lib/
COPY libdcmimgle.so.14 /usr/local/lib/
COPY libdcmiod.so.14 /usr/local/lib/
COPY libdcmjpeg.so.14 /usr/local/lib/
COPY libdcmjpls.so.14 /usr/local/lib/
COPY libdcmnet.so.14 /usr/local/lib/
COPY libdcmpmap.so.14 /usr/local/lib/
COPY libdcmpstat.so.14 /usr/local/lib/
COPY libdcmqrdb.so.14 /usr/local/lib/
COPY libdcmrt.so.14 /usr/local/lib/
COPY libdcmseg.so.14 /usr/local/lib/
COPY libdcmsr.so.14 /usr/local/lib/
COPY libdcmtls.so.14 /usr/local/lib/
COPY libdcmtract.so.14 /usr/local/lib/
COPY libdcmwlm.so.14 /usr/local/lib/
COPY libi2d.so.14 /usr/local/lib/
COPY libijg12.so.14 /usr/local/lib/
COPY libijg8.so.14 /usr/local/lib/
COPY libijg16.so.14 /usr/local/lib/
COPY liboflog.so.14 /usr/local/lib/
COPY libofstd.so.14 /usr/local/lib/
COPY libvtkDICOMParser-9.0.so.1 /usr/local/lib/
COPY libicuuc.so.66 /usr/local/lib/
COPY libvtkIOImage-9.0.so.1 /usr/local/lib/
COPY libvtkImagingCore-9.0.so.1 /usr/local/lib/
COPY libvtkCommonExecutionModel-9.0.so.1 /usr/local/lib/
COPY libvtkCommonDataModel-9.0.so.1 /usr/local/lib/
COPY libvtkCommonCore-9.0.so.1 /usr/local/lib/
COPY libvtkloguru-9.0.so.1 /usr/local/lib/
COPY libvtkCommonMisc-9.0.so.1 /usr/local/lib/
COPY libvtkjpeg-9.0.so.1 /usr/local/lib/
COPY libvtksys-9.0.so.1 /usr/local/lib/
COPY libvtkCommonMath-9.0.so.1 /usr/local/lib/


RUN export LD_LIBRARY_PATH=/usr/local/lib:./

#CMD ["./remote_server", "127.0.0.1" ,"8080","./"] 
CMD ["ldd" ,"./remote_server"]

////THE OUTPUT///

linux-vdso.so.1 (0x00007ffdbd2a2000)
    libvtkIOImage-9.0.so.1 => /usr/local/lib/libvtkIOImage-9.0.so.1 (0x00007fe457f7c000)
    libvtkImagingCore-9.0.so.1 => /usr/local/lib/libvtkImagingCore-9.0.so.1 (0x00007fe457d4e000)
    libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fe457cc5000)
    libaws-cpp-sdk-s3.so => /usr/local/lib/libaws-cpp-sdk-s3.so (0x00007fe457528000)
    libaws-cpp-sdk-core.so => /usr/local/lib/libaws-cpp-sdk-core.so (0x00007fe4571b6000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe457193000)
    libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007fe4570fe000)
    libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fe456e28000)
    libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007fe456d97000)
    libvtkCommonExecutionModel-9.0.so.1 => /usr/local/lib/libvtkCommonExecutionModel-9.0.so.1 (0x00007fe456cd2000)
    libvtkCommonDataModel-9.0.so.1 => /usr/local/lib/libvtkCommonDataModel-9.0.so.1 (0x00007fe45688d000)
    libvtkCommonCore-9.0.so.1 => /usr/local/lib/libvtkCommonCore-9.0.so.1 (0x00007fe45640b000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe456228000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe4560d9000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe4560be000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe455ecc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fe45818e000)
    libvtkDICOMParser-9.0.so.1 => not found
    libvtkmetaio-9.0.so.1 => not found
    libvtkpng-9.0.so.1 => not found
    libvtkpugixml-9.0.so.1 => not found
    libvtktiff-9.0.so.1 => not found
    libvtkzlib-9.0.so.1 => not found
    libvtkCommonSystem-9.0.so.1 => not found
    libvtkCommonTransforms-9.0.so.1 => not found
    libvtkCommonMath-9.0.so.1 => not found
    libvtksys-9.0.so.1 => not found
    libvtkjpeg-9.0.so.1 => not found
    libvtkCommonTransforms-9.0.so.1 => not found
    libvtkCommonMath-9.0.so.1 => not found
    libaws-c-event-stream.so.0unstable => /usr/local/lib/libaws-c-event-stream.so.0unstable (0x00007fe455ebb000)
    libaws-c-common.so.0unstable => /usr/local/lib/libaws-c-common.so.0unstable (0x00007fe455e6b000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe455e65000)
    libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007fe455e3c000)
    libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007fe455e19000)
    librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007fe455df9000)
    libssh.so.4 => /lib/x86_64-linux-gnu/libssh.so.4 (0x00007fe455d8b000)
    libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007fe455d78000)
    libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007fe455d2b000)
    libldap_r-2.4.so.2 => /lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007fe455cd5000)
    liblber-2.4.so.2 => /lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007fe455cc2000)
    libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007fe455cb4000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe455c98000)
    libvtkCommonMisc-9.0.so.1 => not found
    libvtksys-9.0.so.1 => not found
    libvtkCommonTransforms-9.0.so.1 => not found
    libvtkCommonMisc-9.0.so.1 => not found
    libvtkCommonSystem-9.0.so.1 => not found
    libvtkCommonMath-9.0.so.1 => not found
    libvtksys-9.0.so.1 => not found
    libvtksys-9.0.so.1 => not found
    libvtkloguru-9.0.so.1 => not found
    libaws-checksums.so => /usr/local/lib/libaws-checksums.so (0x00007fe455c87000)
    libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007fe455b05000)
    libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007fe45592f000)
    libhogweed.so.5 => /lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007fe4558f5000)
    libnettle.so.7 => /lib/x86_64-linux-gnu/libnettle.so.7 (0x00007fe4558bb000)
    libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fe455837000)
    libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fe45575a000)
    libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fe455729000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fe455722000)
    libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fe455711000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fe4556f5000)
    libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007fe4556d8000)
    libgssapi.so.3 => /lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007fe455693000)
    libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007fe455670000)
    libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007fe455538000)
    libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007fe455522000)
    libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fe45551b000)
    libheimntlm.so.0 => /lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007fe45550f000)
    libkrb5.so.26 => /lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007fe45547c000)
    libasn1.so.8 => /lib/x86_64-linux-gnu/libasn1.so.8 (0x00007fe4553d3000)
    libhcrypto.so.4 => /lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007fe45539b000)
    libroken.so.18 => /lib/x86_64-linux-gnu/libroken.so.18 (0x00007fe455382000)
    libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007fe455376000)
    libwind.so.0 => /lib/x86_64-linux-gnu/libwind.so.0 (0x00007fe45534c000)
    libheimbase.so.1 => /lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007fe455338000)
    libhx509.so.5 => /lib/x86_64-linux-gnu/libhx509.so.5 (0x00007fe4552ea000)
    libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007fe4551c1000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fe455186000)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...