rust-lang / docker-rust

The official Docker images for Rust
436 stars 88 forks source link

GLIBC_2.29 Not Found #105

Closed physics515 closed 2 years ago

physics515 commented 2 years ago

This is my first time trying to create a docker image, so bear with me. I'm not even sure this is the best place to post this issue. I can successfully build the image but when I run the image unsing: docker run -p 80:80 my-app I get an error: ./my-app: /lib/x86_64-linux-gnu/libm.so.6: version 'GLIBC_2.29' not found (required by ./my-app) ./my-app: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.29' not found (required by ./my-app)

My docker file

FROM rust:1.61 as builder
RUN USER=root

RUN mkdir my-app
WORKDIR /my-app
Add . ./
RUN cargo clean && cargo build --release

FROM debian:buster
ARG APP=/user/src/app
RUN mkdir -p {$APP}

# Copy the compiled binaries into the new container.
COPY --from=builder /my-app/target/release/my-app ${APP}/my-app

WORKDIR ${APP}

# install openssl
RUN apt-get update
RUN apt-get install -y wget
RUN apt-get install -y build-essential
RUN apt-get install -y zlib1g-dev
ARG OPENSSL_VERSION=1.1.0g
RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
RUN tar xvfz openssl-${OPENSSL_VERSION}.tar.gz
RUN cd openssl-${OPENSSL_VERSION} && ./config && make && make install
RUN echo '/usr/local/lib' >> /etc/ld.so.conf
RUN cat /etc/ld.so.conf
RUN ldconfig
RUN echo 'export LD_LIBRARY_PATH=/usr/local/lib' >> ~/.bash_profile && . ~/.bash_profile
RUN openssl version

CMD ["./eggersmann-app-server"]

Any ideas what I am doing wrong here?

sfackler commented 2 years ago

You're building in a container built off of Debian Bullseye which has a newer glibc version than Debian Buster, which is what you're trying to run it in. You can update the second container to debian:bullseye and it should work.

physics515 commented 2 years ago

I'm building again now, I'll confirm if it works, but is there any source for how one would come upon such information? Like the differences between Buster and Bullseye, and when to use which container?

sfackler commented 2 years ago

Bullseye and Buster are just the names of the last two stable Debian releases: https://www.debian.org/releases/. Generally speaking, I'd always just use the newest stable release.

physics515 commented 2 years ago

That worked like a charm. Thank you!