0

I am running a rust program on the debian buster slim image, each time i boot up the container i get this error

/usr/local/bin/anti_ghost_ping: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /usr/local/bin/anti_ghost_ping)

This doesnt happen during compile, only during runtime

This is the current dockerimage i have:

FROM rust:1.62.1 as builder

WORKDIR /bot

RUN apt-get update && apt-get install -y cmake && apt-get clean

COPY Cargo.toml Cargo.lock ./
RUN mkdir src && \
    echo "// dummy file" > src/lib.rs && \
    cargo build --release && \
    rm -r src

COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release

FROM debian:buster-slim

RUN apt-get update && apt-get upgrade -y && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

COPY --from=builder /bot/target/release/anti_ghost_ping /usr/local/bin/anti_ghost_ping

CMD ["/usr/local/bin/anti_ghost_ping"]

Ive already done searching on this and found a few posts about it but none are successful.

Leastrio
  • 210
  • 1
  • 2
  • 9
  • Means exactly what it says: the glibc version at runtime isn't the one that compilation was against. Silly question: Which distro is your `builder` image built against, and which glibc version does that `builder` image use? – Charles Duffy Aug 06 '22 at 20:29
  • I've had similar issues trying to build on a system with a new glibc and running on a system with an older glibc. I wound up having to create a docker image with the glibc version from the target system and build on that image, so you may need to do the same thing -- make your own image based on `debian:buster-slim` and install Rust on that. – cdhowie Aug 06 '22 at 20:29
  • Or you could just moot the whole problem by doing a static build so there's no dynamic linking in the first place. – Charles Duffy Aug 06 '22 at 20:29
  • @CharlesDuffy I don't think you can avoid some amount of dynamic linking to libc. – cdhowie Aug 06 '22 at 20:30
  • 1
    (...this isn't in any way a Rust-specific problem; you'd have a similar issue compiling a C program and then transporting the binary to a distro with an incompatible glibc version) – Charles Duffy Aug 06 '22 at 20:30
  • 1
    Change the final image to be `FROM debian:bullseye-slim`. This is a newer release of Debian which has a sufficiently new libc. I explain a little more in the linked question. – David Maze Aug 06 '22 at 20:31
  • @cdhowie, the main place where it tends to be _a little_ tricky to avoid is DNS resolution, but that's specifically a glibc problem. https://github.com/emk/rust-musl-builder exists, so one doesn't _need_ glibc; musl's name service lookup works with purely static linking. (Also, I'd be more than a bit surprised and dismayed if there wasn't an available pure-rust resolver, even if using it meant that one wouldn't have nscd / nslookup / &c settings honored). – Charles Duffy Aug 06 '22 at 20:32

0 Answers0