I am trying to create a simple docker image on top of a Ubuntu base image.
I have a small server program (single executable file) built by g++. The program uses openssl and it works well in my Ubuntu.
Now I want to put the program in a docker image and run it by docker, because I am learning docker.
I used the following Dockerfile:
FROM ubuntu
ARG APPDIR=/usr/local/myserver
WORKDIR ${APPDIR}
# copy my single server program file
COPY build/bin/svr ./
# install openssl into the image
RUN apt-get -y update
RUN apt-get -y install openssl
#RUN apt-get -y install libssl-dev
# run the server program
EXPOSE 1080
EXPOSE 1443
CMD ./svr
No matter I install openssl or libssl-dev, the docker image just failed to run with the following error:
./svr: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
I googled a lot with no luck. How can I fix this? Thanks!!
I found out that the "libssl.so.1.1" that my program is referencing is missing from the docker image. I used "CMD find /usr -name libssl*" to check what ssl dlls are available in the image and it turned out only the "libssl3.so" is in the image.
I am using Ubuntu 20 and I installed the openssl sdk by "apt install libssl-dev". It seems the sdk is only for v1.1... The problem is that, on Ubuntu, if you do "apt install libssl-dev", you get the sdk for 1.1 and if you do "apt install openssl", you get libssl3.so.
I know I can manually copy the .so.1.1 into my docker image instead of running apt-get, but I don't think it to be a graceful approach.
I was having this problem as well. It was puzzling because initially I was running my project using the
rustDocker image right after building it in the same image. When I switched to a builder pattern, I was using theubuntuimage as my runner image and was unable to locate a suitable package providing this library.I dug around and found out that the
rustimage is based on thedebianimage and in the first layer installs thelibssl1.1package using APT. Replicating this solved my problem: