multistage Docker build with dynamically linked program
Clash Royale CLAN TAG#URR8PPP
multistage Docker build with dynamically linked program
I am working on packaging a dynamically linked c program with docker using multi-sage builds but I am missing a library or something:
FROM debian:9.5-slim as builder
WORKDIR /openconnect
RUN apt update && apt install -y
build-essential
gettext
autoconf
automake
libproxy-dev
libxml2-dev
libtool
vpnc-scripts
pkg-config
libgnutls28-dev
ADD . .
RUN ./autogen.sh
RUN ./configure
--with-vpnc-script=/etc/vpnc/vpnc-script
--without-openssl-version-check
RUN make
RUN make install
RUN ldconfig
FROM builder as gatherer
RUN mkdir /gathered
RUN ldd /usr/local/sbin/openconnect | grep "=> /" | awk 'print $3' | xargs -I '' sh -c "cp -v --parents /gathered"
RUN cp --parents /usr/local/sbin/openconnect /gathered
FROM debian:9-slim
COPY --from=gatherer /gathered /
ENTRYPOINT ["/usr/local/sbin/openconnect"]
When I run the container is get:
/usr/local/sbin/openconnect: error while loading shared libraries: libopenconnect.so.5: cannot open shared object file: No such file or directory
I have verified that "/usr/local/lib/libopenconnect.so.5" exists in the final image. Also if I skip out on the multistage then the container runs just fine.
What am I missing?
debian:9.5-slim
debian:9-slim
Is the library in the linker path in the run env image?
– Matt Schuchard
Aug 12 at 13:51
why are you using 3 images? is it running on the gatherer image?
– gCoh
Aug 12 at 14:08
@byrnedo thanks for catching that. No change after using the intended debian:9.5-slim in the final stage
– Tom
Aug 12 at 19:45
@gCoh Yes, it works from gatherer just as it does from builder, but gatherer is from builder and is not "clean". Also does not work if I move the gather steps to builder and copy from builder in the final stage. The middle stage makes no difference.
– Tom
Aug 12 at 19:50
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What happens if you use the same
debian:9.5-slim
image which you use in the builder stage in the final stage? Currently you usedebian:9-slim
...– byrnedo
Aug 12 at 11:07