Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

I am new to docker, and it is my first time meeting such error.

This is my DockerFile

FROM rust:latest as builder
ENV APP mapservice
WORKDIR /usr/src/$APP
COPY . .
RUN cargo install --path .
 
FROM debian:buster-slim
RUN apt-get update && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/$APP /usr/local/bin/$APP
#export this actix web service to port 8080 and 0.0.0.0
EXPOSE 8080
CMD ["mapservice"]

And when I run

docker run -it --rm -p 8080:8080 mapservice

I got an error like: mapservice: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

I have no idea why would I got this error. Perhaps I have my APIKEY hardcoded in the main.rs??Does anyone know how to fix this problem? My laptop is M1pro Mac.

I try to run another sample project with a similar dockerfile, and everything is fine with it. I also tried to deploy it on AWS, which gives me another health check error on 8080. Is it something wrong with my docker file?

like image 411
Eugene Avatar asked Feb 10 '26 00:02

Eugene


2 Answers

This error is because you have copied over the built executable to a new base image which does not have libssl.so.1.1 installed. To fix, you'll need to install the dependency before the CMD step via a package install.

One way to fix this is to install the openssl package by adding RUN apt-get update && apt install -y openssl before the CMD step. You can also dive into installing just the libssl library itself, more info here: https://packages.debian.org/buster/libssl-dev. There are other packages which will also install this dependency. Ultimately the package chosen for installation will depend on your use case.

like image 104
Jjack Avatar answered Feb 12 '26 15:02

Jjack


Using openssl as a dependency like

openssl = { version = "0.10.59", features = ["vendored"] }

did fix it for me

like image 26
Hillkorn Avatar answered Feb 12 '26 14:02

Hillkorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!